From 3e2cc8c3488ac4bfb94f4621445f58ac9ed1f97f Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Tue, 26 Jul 2016 19:53:11 +0300 Subject: [PATCH] #ARC-18 Add stages and update stages for customer --- api/views.py | 7 +- archilance/settings/base.py | 3 +- chat/templates/chat_customer.html | 133 ++++++++++++++++-------- chat/templates/test1.html | 41 ++++++-- chat/views.py | 4 +- projects/serializers.py | 11 ++ users/templates/contractor_profile.html | 1 + 7 files changed, 140 insertions(+), 60 deletions(-) diff --git a/api/views.py b/api/views.py index 5e5ec84..a8d358d 100755 --- a/api/views.py +++ b/api/views.py @@ -1,6 +1,6 @@ from django.db.models import Q from rest_framework.viewsets import ModelViewSet - +from rest_framework import permissions from projects.models import Project, Realty, Stage from projects.serializers import ProjectSerializer, RealtySerializer, StageSerializer @@ -27,6 +27,11 @@ class StageViewSet(ModelViewSet): queryset = Stage.objects.all() serializer_class = StageSerializer filter_class = StageFilterSet + permission_classes = (permissions.IsAuthenticatedOrReadOnly,) + + # def put(self, request, *args, **kwargs): + # # import code; code.interact(local=dict(globals(), **locals())) + # return super().update(request, *args, **kwargs) class ProjectViewSet(ModelViewSet): diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 8b68b49..79509db 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -238,9 +238,10 @@ REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly', + # 'rest_framework.permissions.DjangoModelPermissions', ], - 'PAGE_SIZE': 10, + 'PAGE_SIZE': 100, 'DEFAULT_FILTER_BACKENDS': ('rest_framework_filters.backends.DjangoFilterBackend',), # djangorestframework-filters } diff --git a/chat/templates/chat_customer.html b/chat/templates/chat_customer.html index 5e9c52e..0a9a607 100644 --- a/chat/templates/chat_customer.html +++ b/chat/templates/chat_customer.html @@ -156,7 +156,7 @@
-
+ @@ -174,43 +174,47 @@ -
-

Этапы работы

-
-

1 / Согласование условий

-

- Обсуджение задания и условий выполнения работы. Подтверждение заказа исполнителем. -

-

-

- Какое кол-во этапов подразумевает работа? -

- -
-
-
-

- Этап -

-
- - - - - - - +
+

Этапы работы

+
+

1 / Согласование условий

+

+ Обсуджение задания и условий выполнения работы. Подтверждение заказа исполнителем. +

+

+ +
+
+

+ Какое кол-во этапов подразумевает работа? +

+ - +
- +
+
@@ -241,23 +245,48 @@ var csrftoken = getCookie('csrftoken'); - $('#countStage').on('change', function(e){ - $(".stages_form").each(function(){ + $("#addStagesForm").on('click',function(){ + $(".new-stages-form").each(function(i,v){ + $.ajax({ + url: '/api/stages/', + type: 'POST', + beforeSend: function (xhr) { + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) + }, + data:$(this).serialize(), + dataType: 'json', + success: function (json) { + console.log(json); + }, + error: function(e){ + console.log(e); + } + }); + + }); + }); + + $('#countStage').on('change', function (e) { + $(".stages_form").each(function () { $(this).remove(); }); var countStage = parseInt($(this).val()); var limitCount = countStage + 1; - for(var i=2;i
' + - '

'+ senderName +'

'+ v.created +'
' + + inbox.innerHTML += '
' + + '

' + senderName + '

' + v.created + '
' + '

' + v.text + '

'; }); } @@ -296,10 +325,22 @@ success: function (json) { var htmlInbox = ""; $.each(json.results, function (i, v) { - htmlInbox += '
' + - '

Этап '+ v.pos +''+ v.name +'

' + - '

Результаты этапа:'+ v.result+'

' + - '

до 16.03.2015

'+ v.cost +'
'; + if (v.status == "not_agreed") { + htmlInbox += '
' + + '

Этап

' + + '' + + '' + + '' + + '' + + '' + + '
'; + } else { + htmlInbox += '
' + + '

Этап ' + v.pos + '' + v.name + '

' + + '

Результаты этапа:' + v.result + '

' + + '

до 16.03.2015

' + v.cost + '
'; + + } }); $("#order-stages").html(htmlInbox); } diff --git a/chat/templates/test1.html b/chat/templates/test1.html index 2531df0..97e9bd9 100644 --- a/chat/templates/test1.html +++ b/chat/templates/test1.html @@ -1,10 +1,33 @@ -

Test page

+{% extends 'partials/base.html' %} +{% block content %} +

Test page

+{% endblock %} +{% block js_block %} + + +{% endblock %} diff --git a/chat/views.py b/chat/views.py index 1268f22..ed44c24 100644 --- a/chat/views.py +++ b/chat/views.py @@ -53,6 +53,4 @@ class ChatUserView(View): def test(request): - ArticleFormSet = formset_factory(ArticleForm, extra=2) - formset = ArticleFormSet() - return render(request, 'test1.html', {'formset': formset}) + return render(request, 'test1.html') diff --git a/projects/serializers.py b/projects/serializers.py index 45cf44a..a9ac96c 100755 --- a/projects/serializers.py +++ b/projects/serializers.py @@ -80,6 +80,17 @@ class StageSerializer(ModelSerializer): ) + # def update(self, inst, validated_data): + # import code; code.interact(local=dict(globals(), **locals())) + # inst.id = validated_data.get('id',inst.id) + # inst.name = validated_data.get('name', inst.name) + # inst.cost = validated_data.get('cost', inst.cost) + # inst.order = validated_data.get('order', inst.order) + # inst.result = validated_data.get('result', inst.result) + # inst.save() + # return inst + + class ProjectSerializer(ModelSerializer): customer = UserSerializer() specialization = SpecializationSerializer() diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index 0cdaa44..606a110 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -287,6 +287,7 @@
{{ contractor.contractor_resume.text }} +