From deb89e128ccde2c6ba99a4ba9d0f27ac568bd9f4 Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Mon, 12 Sep 2016 13:03:41 +0300 Subject: [PATCH] #ARC-11 (5), #ARC-14 (20, 21) --- common/views.py | 7 +++-- projects/templates/project_detail.html | 29 ++++++++++++++++++- projects/views.py | 4 ++- users/forms.py | 7 ++++- .../customer_profile_open_projects.html | 10 ++++--- users/templates/user_profile_edit.html | 15 ++++++---- 6 files changed, 58 insertions(+), 14 deletions(-) diff --git a/common/views.py b/common/views.py index f1be61c..a09281c 100644 --- a/common/views.py +++ b/common/views.py @@ -136,9 +136,9 @@ class CustomRegistrationView(RegistrationView): def register(self, form): user = super().register(form) - if form.cleaned_data.get('customer'): + if form.cleaned_data.get('user_type') == 'customer': group = Group.objects.get(name='Заказчики') - elif form.cleaned_data.get('contractor'): + elif form.cleaned_data.get('user_type') == 'contractor': group = Group.objects.get(name='Исполнители') else: group = None @@ -151,3 +151,6 @@ class CustomRegistrationView(RegistrationView): user.save() return user + + +# import code; code.interact(local=dict(globals(), **locals())) diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 4cdf3e9..1d49102 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -518,7 +518,7 @@ {% elif request.user.is_customer and project in request.user.customer_projects.all %}
-

Исполнители

+

Исполнители

@@ -1079,3 +1079,30 @@
{% endblock %} + + +{% block js_block %} + +{% endblock %} diff --git a/projects/views.py b/projects/views.py index f29abe5..9fd0989 100644 --- a/projects/views.py +++ b/projects/views.py @@ -652,7 +652,9 @@ def add_candidate(request, answer_id, project_id): if not candidate: Candidate.objects.create(answer=answer, project=project, position=count_answers) - return redirect('projects:detail', pk=project_id) + + redirect_to = '%s%s' % (reverse('projects:detail', kwargs={'pk': project_id}), '#answers') + return redirect(redirect_to) class CandidateDeleteView(DeleteView): diff --git a/users/forms.py b/users/forms.py index d148a40..ffd11b7 100644 --- a/users/forms.py +++ b/users/forms.py @@ -53,6 +53,7 @@ class UserProfileEditForm(forms.ModelForm): fields = ( 'contractor_specializations', + 'contractor_status', 'cro', 'date_of_birth', 'first_name', @@ -67,12 +68,16 @@ class UserProfileEditForm(forms.ModelForm): ) widgets = { - 'date_of_birth': forms.TextInput(attrs={'class': 'datepicker'}), # TODO: Use common format with jQueryUI Datepicker + # TODO: Use common format with jQueryUI Datepicker: + 'date_of_birth': forms.TextInput(attrs={'class': 'datepicker box-sizing surr surr2'}), } def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') super().__init__(*args, **kwargs) + + attrs = self.fields['contractor_status'].widget.attrs + attrs['class'] = _.join(_.compact((attrs.get('class'), 'box-sizing surr surr2')), ' ') class UserProfileBasicInfoEditForm(forms.ModelForm): diff --git a/users/templates/customer_profile_open_projects.html b/users/templates/customer_profile_open_projects.html index 672d6fd..9e112be 100644 --- a/users/templates/customer_profile_open_projects.html +++ b/users/templates/customer_profile_open_projects.html @@ -1,5 +1,7 @@ {% extends 'partials/base.html' %} +{% load project_tags %} + {% block content %} {% include 'partials/header.html' %} @@ -29,7 +31,7 @@
- {% if request.user.is_customer %} + {% if request.user == customer %}

Разместить заказ @@ -52,9 +54,9 @@

diff --git a/users/templates/user_profile_edit.html b/users/templates/user_profile_edit.html index 6f1216d..775ea2c 100644 --- a/users/templates/user_profile_edit.html +++ b/users/templates/user_profile_edit.html @@ -118,16 +118,17 @@

-
Дата рождения
-
Пол
+
Дата рождения
+
Пол
+
Статус
-
+
{{ form.date_of_birth }}
-
+
{% for id, text in form.gender.field.choices %}
+ +
+ {{ form.contractor_status }} +
Сайт
Skype
Телефон
-
Телефон 2
+
Второй телефон