From 92c471386605c5c69e02dec30f47fe28cdaaf031 Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Thu, 23 Jun 2016 10:26:52 +0300 Subject: [PATCH] #ARC-6 add phone field --- projects/templates/project_list.html | 38 +++---------- users/admin.py | 2 +- users/forms.py | 3 + users/migrations/0017_user_phone.py | 20 +++++++ users/models.py | 2 +- users/templates/contractor_profile.html | 21 +++++-- users/templates/contractor_profile_edit.html | 59 ++++++++++++++------ users/views.py | 9 ++- 8 files changed, 96 insertions(+), 58 deletions(-) create mode 100644 users/migrations/0017_user_phone.py diff --git a/projects/templates/project_list.html b/projects/templates/project_list.html index 9a91273..a41a3cb 100644 --- a/projects/templates/project_list.html +++ b/projects/templates/project_list.html @@ -21,29 +21,21 @@
@@ -84,29 +76,21 @@
@@ -164,22 +148,12 @@ 0 ответ от имени группы -

- {{ proj.text }} -

+

{{ proj.text }}

@@ -190,9 +164,11 @@ {% if proj.secure_deal %}
  • Безопасная сделка
  • {% endif %} +
  • Стадия: "П"
  • +
  • Отказаться и переместить в корзину diff --git a/users/admin.py b/users/admin.py index eb231f7..227bdbd 100644 --- a/users/admin.py +++ b/users/admin.py @@ -5,7 +5,7 @@ from .models import User, Team, ContractorFinancialInfo class UserAdmin(admin.ModelAdmin): readonly_fields = ('pk',) - list_display = ('email','get_groups','is_active',) + list_display = ('email', 'get_groups', 'cro', 'is_active',) def get_groups(self, obj): return ', '.join(g.name for g in obj.groups.all()) diff --git a/users/forms.py b/users/forms.py index b34e3f5..a3051bf 100644 --- a/users/forms.py +++ b/users/forms.py @@ -27,6 +27,9 @@ class UserEditForm(ModelForm): 'skype', 'avatar', 'contractor_specializations', + 'cro', + 'phone', + 'gender', ) widgets = { diff --git a/users/migrations/0017_user_phone.py b/users/migrations/0017_user_phone.py new file mode 100644 index 0000000..6c51e9d --- /dev/null +++ b/users/migrations/0017_user_phone.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-22 14:03 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0016_auto_20160617_1815'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='phone', + field=models.CharField(blank=True, max_length=30, null=True), + ), + ] diff --git a/users/models.py b/users/models.py index a58ac85..8439982 100644 --- a/users/models.py +++ b/users/models.py @@ -99,7 +99,7 @@ class User(AbstractBaseUser, PermissionsMixin): website = models.CharField(max_length=255, blank=True) date_of_birth = models.DateTimeField() avatar = models.ImageField(upload_to='users/avatars/', blank=True) - + phone = models.CharField(max_length=30, blank=True, null=True) @property def is_staff(self): diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index 38407a0..ff950e4 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -17,30 +17,38 @@
  • @@ -63,10 +71,15 @@
    {% load projects_tags %} {% ratings_widget contractor.pk %} -
    -
    -

    Есть допуск СРО

    -
    + + {% if contractor.cro %} +
    +
    +

    Есть допуск СРО

    +
    + {% endif %} + +
    diff --git a/users/templates/contractor_profile_edit.html b/users/templates/contractor_profile_edit.html index f2f8786..1e06465 100644 --- a/users/templates/contractor_profile_edit.html +++ b/users/templates/contractor_profile_edit.html @@ -7,6 +7,17 @@
    {% csrf_token %}
    +{% load mptt_tags %} + {% recursetree nodes %} +
  • + {{ node.name }} + {% if not node.is_leaf_node %} + --- + {{ children }} + + {% endif %} +
  • + {% endrecursetree %} {{ form.errors }}
    @@ -81,37 +92,39 @@
    Дата рождения:
    -
    Пол:
    +
    Пол:
    {{ form.date_of_birth }}
    - + +

    Мужской

    - +

    Женский

    Сайт:
    Skype:
    -{#
    Электронная почта:
    #} +
    Телефон:
    - +
    +
    - +
    -{#
    #} -{# #} -{#
    #} +
    - +
    @@ -161,6 +174,23 @@ }); var csrftoken = getCookie('csrftoken'); + $('#id_date_of_birth_day').addClass('selectpicker2 valul'); + $('#id_date_of_birth_month').addClass('selectpicker left-edit'); + $('#id_date_of_birth_year').addClass('selectpicker5 valul left-edit'); + + $('.selectpicker2').selectpicker({ + style: 'btn-info', + size: 4, + width: '90px' + }); + + + $('.selectpicker5').selectpicker({ + style: 'btn-info', + size: 4, + width: '117px' + }); + $.ajax({ url: '/api/location', type: 'GET', @@ -170,7 +200,6 @@ console.log(json.results); var out = '' var outCountry = ''; - $.each(json.results, function(i,v){ if (v.type == 'country'){ outCountry += ''; @@ -179,24 +208,18 @@ out += ''; } }); - $('#location-country').html(outCountry); $('#location-city').html(out); $('#location-country').addClass("selectpicker4"); $('#location-city').addClass("selectpicker4"); + $('.selectpicker4').selectpicker({ style: 'btn-info', size: 4, width: '237px' }); - } - }); - - - - }); {% endblock %} diff --git a/users/views.py b/users/views.py index f272eb1..e6f5bd4 100644 --- a/users/views.py +++ b/users/views.py @@ -6,6 +6,7 @@ from django.views.generic.base import TemplateView from django.core.urlresolvers import reverse from archilance.mixins import BaseMixin +from specializations.models import Specialization from .models import User, ContractorFinancialInfo from .mixins import CheckForUserMixin from .forms import UserEditForm, ContractorFinancicalInfoForm @@ -76,7 +77,8 @@ class CustomerProfileEditView(CheckForUserMixin, View): def get(self, request, *args, **kwargs): instance = get_object_or_404(User, pk=request.user.pk) form = self.form_class(instance=instance) - return render(request,self.template_name, {'form': form }) + nodes = Specialization.objects.all() + return render(request,self.template_name, {'form': form , 'nodes': nodes}) def post(self, request, *args, **kwargs): instance = request.user @@ -96,13 +98,14 @@ class ContractorProfileEditView(CheckForUserMixin, View): def get(self, request, *args, **kwargs): instance = get_object_or_404(User, pk=request.user.pk) form = self.form_class(instance=instance) - return render(request, self.template_name, {'form': form}) + nodes = Specialization.objects.all() + return render(request,self.template_name, {'form': form , 'nodes': nodes}) def post(self, request, *args, **kwargs): instance = request.user form = self.form_class(request.POST, request.FILES, instance=instance) if form.is_valid(): - # import code; code.interact(local=dict(globals(), **locals())) + import code; code.interact(local=dict(globals(), **locals())) instance = form.save(commit=False) instance.save() messages.info(request, 'Данные успешно отредактированы')