From becf37b62981e4883749ee012cd6ba86bcfee543 Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Mon, 25 Jul 2016 10:30:20 +0300 Subject: [PATCH] #ARC-27 --- api/views.py | 8 +- archilance/settings/base.py | 11 + archilance/urls.py | 1 + archilance/util.py | 14 ++ common/templatetags/common_tags.py | 20 +- projects/forms.py | 16 +- projects/models.py | 4 +- requirements/base.txt | 1 + .../0002_remove_review_is_secured.py | 19 ++ reviews/models.py | 1 - specializations/views.py | 4 +- users/forms.py | 8 +- .../contractor_financical_info_edit.html | 207 +++++++++--------- users/templates/contractor_profile.html | 2 + users/templates/contractor_profile_edit.html | 7 +- .../customer_profile_current_projects.html | 2 + users/templates/customer_profile_edit.html | 3 + .../customer_profile_open_projects.html | 1 + users/templates/customer_profile_reviews.html | 33 ++- users/views.py | 30 ++- work_sell/forms.py | 4 +- 21 files changed, 261 insertions(+), 135 deletions(-) create mode 100644 reviews/migrations/0002_remove_review_is_secured.py diff --git a/api/views.py b/api/views.py index 8aaeff2..bc6f52e 100755 --- a/api/views.py +++ b/api/views.py @@ -55,8 +55,8 @@ class RealtyViewSet(ModelViewSet): class SpecializationViewSet(ModelViewSet): - # queryset = Specialization.objects.root_nodes()[0].get_descendants() - queryset = Specialization.objects # TODO: Tmp + queryset = Specialization.objects.root_nodes()[0].get_descendants() + # queryset = Specialization.objects # Migrate with this enabled serializer_class = SpecializationSerializer filter_class = SpecializationFilterSet @@ -68,7 +68,7 @@ class UserViewSet(ModelViewSet): class LocationViewSet(ModelViewSet): - # queryset = Location.objects.root_nodes()[0].get_descendants() - queryset = Location.objects # TODO: Tmp + queryset = Location.objects.root_nodes()[0].get_descendants() + # queryset = Location.objects # Migrate with this enabled serializer_class = LocationSerializer filter_class = LocationFilterSet diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 9cb8382..8b68b49 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -39,6 +39,7 @@ THIRD_PARTY_APPS = [ 'sorl.thumbnail', 'compressor', 'password_reset', + 'mathfilters', # Basic math operations in templates; https://pypi.python.org/pypi/django-mathfilters ] LOCAL_APPS = [ @@ -74,6 +75,7 @@ TEMPLATES = [ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(ROOT_DIR, 'templates')], 'APP_DIRS': True, + 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', @@ -81,6 +83,15 @@ TEMPLATES = [ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], + + + # Load these templatetags by default: + + 'builtins': [ + 'django.templatetags.static', + 'mathfilters.templatetags.mathfilters', + 'common.templatetags.common_tags', + ], }, }, ] diff --git a/archilance/urls.py b/archilance/urls.py index 5a4f83b..0f7eead 100644 --- a/archilance/urls.py +++ b/archilance/urls.py @@ -7,6 +7,7 @@ from django.views.generic import TemplateView from .views import HomeTemplateView, TestChatTemplateView + urlpatterns = [ url(r'^$', HomeTemplateView.as_view()), url('', include('social.apps.django_app.urls', namespace='social')), diff --git a/archilance/util.py b/archilance/util.py index 6b8f157..c96141b 100644 --- a/archilance/util.py +++ b/archilance/util.py @@ -49,3 +49,17 @@ def model_fields(model, width=200): 'Blank? %s' % f.blank if not f.is_relation else '(relation)', 'Hidden? %s' % (f.is_hidden() if hasattr(f, 'is_hidden') else False), ) for f in model._meta.get_fields(include_hidden=True)], width=width) + + +def lorem(sentences=5): + words = _.split(( + 'a ac adipiscing amet ante arcu at auctor augue bibendum commodo condimentum consectetur consequat convallis curabitur' + 'cursus diam dictum dignissim dolor donec duis efficitur eget eleifend elit enim erat et eu ex facilisis faucibus feugiat' + 'finibus gravida iaculis id imperdiet in integer ipsum lacinia lacus laoreet lectus leo libero ligula lobortis lorem' + 'luctus maecenas mauris metus mi mollis morbi nam nec neque nisi non nulla nullam nunc odio orci ornare pellentesque' + 'pharetra phasellus porta porttitor posuere pretium proin pulvinar purus quam quis rhoncus rutrum sapien sed sem semper' + 'sit sollicitudin tempor tempus tincidunt tortor turpis ullamcorper ultricies ut varius vehicula vel velit vestibulum' + 'vitae viverra volutpat vulputate' + ), ' ') + + return _.join(_.times(lambda i_: _.capitalize(_.join(_.sample(words, _.random(5, 30)), ' ')), sentences), '. ') diff --git a/common/templatetags/common_tags.py b/common/templatetags/common_tags.py index f73a9a0..d83c232 100644 --- a/common/templatetags/common_tags.py +++ b/common/templatetags/common_tags.py @@ -2,15 +2,17 @@ from django import template from pprint import pprint, pformat import os -register = template.Library() +from archilance import util + +register = template.Library() # @register.inclusion_tag('templatetags/inspect.html', takes_context=True) # def inspect(context, obj): # return {'obj': pformat(obj.__dict__)} -@register.filter('inspect') +@register.filter def inspect(obj): return pformat(obj.__dict__) @@ -30,7 +32,12 @@ def to_str(val): return str(val) -@register.filter('class_name') +@register.filter('range') +def to_range(num): + return range(num) + + +@register.filter def class_name(val): return type(val).__name__ @@ -40,9 +47,14 @@ def multiply(string, times): return string * times -@register.filter('basename') +@register.filter def basename(val): return os.path.basename(val) +@register.simple_tag +def lorem(*args, **kwargs): + return util.lorem(*args, **kwargs) + + # import code; code.interact(local=dict(globals(), **locals())) diff --git a/projects/forms.py b/projects/forms.py index c5cb322..a6a1222 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -46,8 +46,8 @@ class ProjectFilterForm(forms.ModelForm): self.fields['specialization'].required = False - # self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants() - self.fields['specialization'].queryset = Specialization.objects # TODO: Tmp + self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants() + # self.fields['specialization'].queryset = Specialization.objects # Migrate with this enabled class ProjectFilterRealtyForm(forms.ModelForm): @@ -75,8 +75,8 @@ class ProjectFilterRealtyForm(forms.ModelForm): self.fields['construction_type'].empty_label = '' self.fields['construction_type'].required = False - # self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants() - self.fields['location'].queryset = Location.objects # TODO: Tmp + self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants() + # self.fields['location'].queryset = Location.objects # Migrate with this enabled class CustomerProjectEditForm(forms.ModelForm): @@ -117,8 +117,8 @@ class CustomerProjectEditForm(forms.ModelForm): self.fields['realty'].empty_label = 'Создать новый' - # self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants() - self.fields['specialization'].queryset = Specialization.objects # TODO: Tmp + self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants() + # self.fields['specialization'].queryset = Specialization.objects # Migrate with this enabled if self.instance.pk: self.fields['files'].queryset = self.instance.files @@ -144,8 +144,8 @@ class RealtyForm(forms.ModelForm): self.request = kwargs.pop('request') super().__init__(*args, **kwargs) - # self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants() - self.fields['location'].queryset = Location.objects # TODO: Tmp + self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants() + # self.fields['location'].queryset = Location.objects # Migrate with this enabled class Realty1Form(forms.Form): diff --git a/projects/models.py b/projects/models.py index df4edcd..70f05aa 100644 --- a/projects/models.py +++ b/projects/models.py @@ -65,8 +65,8 @@ class Project(models.Model): ) DEAL_TYPES = ( - ('secure_deal', 'Безопасная сделка (с резервированием бюджета) '), - ('direct_payment', 'Прямая оплата Исполнителю на его кошелек/счет'), + ('secure_deal', 'Безопасная сделка'), # "Безопасная сделка (с резервированием бюджета)" + ('direct_payment', 'Прямая оплата'), # "Прямая оплата Исполнителю на его кошелек/счет" ) STATES = ( diff --git a/requirements/base.txt b/requirements/base.txt index 790f1a6..cfc10d3 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -37,3 +37,4 @@ sorl-thumbnail==12.3 sqlparse==0.1.19 tornado==4.3 natsort +django-mathfilters diff --git a/reviews/migrations/0002_remove_review_is_secured.py b/reviews/migrations/0002_remove_review_is_secured.py new file mode 100644 index 0000000..119a733 --- /dev/null +++ b/reviews/migrations/0002_remove_review_is_secured.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-24 12:51 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('reviews', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='review', + name='is_secured', + ), + ] diff --git a/reviews/models.py b/reviews/models.py index 56b7358..c51ee6e 100644 --- a/reviews/models.py +++ b/reviews/models.py @@ -2,7 +2,6 @@ from django.db import models from django.core.validators import MaxValueValidator, MinValueValidator class Review(models.Model): - is_secured = models.BooleanField(default=False) project = models.ForeignKey('projects.Project', related_name='reviews') stars = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(5)]) text = models.TextField() diff --git a/specializations/views.py b/specializations/views.py index 2f9b68d..98cf314 100644 --- a/specializations/views.py +++ b/specializations/views.py @@ -15,8 +15,8 @@ class SpecListView(ListView): context['root'] = root context['children'] = root.get_children() - # context['roots'] = Specialization.objects.root_nodes() - context['roots'] = Specialization.objects.filter(name='_root') # TODO: Tmp + context['roots'] = Specialization.objects.root_nodes() + # context['roots'] = Specialization.objects.filter(name='_root') # Migrate with this enabled return context diff --git a/users/forms.py b/users/forms.py index 4142b84..cf3b0ec 100644 --- a/users/forms.py +++ b/users/forms.py @@ -62,14 +62,14 @@ class ContractorFilterForm(forms.Form): reverse_order = forms.BooleanField(required=False) specialization = forms.ModelChoiceField( - # queryset=Specialization.objects.root_nodes()[0].get_descendants(), - queryset=Specialization.objects, # TODO: Tmp, + queryset=Specialization.objects.root_nodes()[0].get_descendants(), + # queryset=Specialization.objects, # Migrate with this enabled required=False, ) location = forms.ModelChoiceField( - # queryset=Location.objects.root_nodes()[0].get_descendants(), - queryset=Location.objects, # TODO: Tmp + queryset=Location.objects.root_nodes()[0].get_descendants(), + # queryset=Location.objects, # Migrate with this enabled required=False, ) diff --git a/users/templates/contractor_financical_info_edit.html b/users/templates/contractor_financical_info_edit.html index f46d235..1a8e67c 100644 --- a/users/templates/contractor_financical_info_edit.html +++ b/users/templates/contractor_financical_info_edit.html @@ -1,7 +1,11 @@ {% extends 'partials/base.html' %} + {% load staticfiles %} + + {% block content %} {% include 'partials/header.html' %} +
@@ -68,123 +72,124 @@
-
{% csrf_token %} -
- {{ form.errors }} -
-
-
Имя, Фамилия, Отчество:
-
Дата рождения:
-
Телефон
-
-
-
- -
-
- -
-
- -
-
-
-
Резиденство:
-
-
- - {% for residency in form.residency %} + {% csrf_token %} +
+ {{ form.errors }} +
+
+
Имя, Фамилия, Отчество:
+
Дата рождения:
+
Телефон
+
+
+
+ +
+
+ +
- -

- {{ residency.choice_label }} -

+ +
- {% endfor %} -
-
-
Юридический статус:
-
-
- {% for lstatus in form.legal_status %} -
- -

- {{ lstatus.choice_label }} -

-
- {% endfor %} -
-
-
Серия и номер паспорта:
-
Кем выдан:
-
-
-
- +
+
Резиденство:
+
+
+ + {% for residency in form.residency %} +
+ +

+ {{ residency.choice_label }} +

+
+ {% endfor %}
-
- +
+
Юридический статус:
-
- +
+ {% for lstatus in form.legal_status %} +
+ +

+ {{ lstatus.choice_label }} +

+
+ {% endfor %}
-
-
-
Код подразделения:
-
Кем выдан:
-
-
-
- +
+
Серия и номер паспорта:
+
Кем выдан:
-
- +
+
+ +
+
+ +
+
+ +
-
-
-
Дата выдачи:
-
Почтовый адрес:
-
-
-
- +
+
Код подразделения:
+
Кем выдан:
-
-{# #} +
+
+ +
+
+ +
-
-
-
ИНН:
-
Яндекс.Деньги:
-
Номер карты
-
Скан-копии страниц паспорта
-
-
-
- +
+
Дата выдачи:
+
Почтовый адрес:
-
- +
+
+ +
+
+{# #} +
-
- +
+
ИНН:
+
Яндекс.Деньги:
+
Номер карты
+
Скан-копии страниц паспорта
-
- {{ form.passport_scan.value }} -
- - -

Прикрепить файл

+
+
+ +
+
+ +
+
+ +
+
+ {{ form.passport_scan.value }} +
+ + +

Прикрепить файл

+
-
-
-
- + + {% include 'partials/footer.html' %}
diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index 547575f..40109d3 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -2,6 +2,8 @@ {% load staticfiles %} {% load thumbnail %} + + {% block content %} {% include 'partials/header.html' %} diff --git a/users/templates/contractor_profile_edit.html b/users/templates/contractor_profile_edit.html index 42413cf..2d733c7 100644 --- a/users/templates/contractor_profile_edit.html +++ b/users/templates/contractor_profile_edit.html @@ -1,8 +1,12 @@ {% extends 'partials/base.html' %} + {% load staticfiles %} {% load common_tags %} + + {% block content %} -{% include 'partials/header.html' %} + {% include 'partials/header.html' %} +
{% csrf_token %} @@ -127,6 +131,7 @@
{% endblock %} + {% block js_block %}