diff --git a/archilance/management/commands/generate_reviews.py b/archilance/management/commands/generate_reviews.py
index d902b73..98f8a94 100644
--- a/archilance/management/commands/generate_reviews.py
+++ b/archilance/management/commands/generate_reviews.py
@@ -23,7 +23,7 @@ class Command(BaseCommand):
review.project = Project.objects.order_by('?').first()
review.stars = _.random(1, 5)
- review.text = util.lorem(_.random(5, 15))
+ review.text = util.lorem()
review.is_secured = _.sample((True, False))
review.save()
diff --git a/archilance/management/commands/generate_users.py b/archilance/management/commands/generate_users.py
index 72c81cb..5940f83 100644
--- a/archilance/management/commands/generate_users.py
+++ b/archilance/management/commands/generate_users.py
@@ -81,6 +81,7 @@ class Command(BaseCommand):
return User.objects.create(
first_name='Василий',
last_name='Пупкин',
+ patronym='Иванович',
username=username,
email='%s@example.com' % username,
is_active=True,
diff --git a/archilance/util.py b/archilance/util.py
index c2edc56..adbd3a1 100644
--- a/archilance/util.py
+++ b/archilance/util.py
@@ -1,6 +1,7 @@
from django.shortcuts import _get_queryset
from django.utils import timezone
from pprint import pprint, pformat
+import natsort
import pydash as _; _.map = _.map_; _.filter = _.filter_
import random
@@ -59,13 +60,14 @@ def get_attr_or_none(klass, *args, attr=None, **kwargs):
def model_fields(model, width=200):
+ fields = natsort.natsorted(model._meta.get_fields(), key=lambda f: f.name)
+
pprint([(
f.name,
'Relation? %s' % f.is_relation,
'Null? %s' % f.null,
'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)
+ ) for f in fields], width=width)
def lorem(sentences=5):
diff --git a/projects/migrations/0004_auto_20160726_1931.py b/projects/migrations/0004_auto_20160726_1931.py
new file mode 100644
index 0000000..d703839
--- /dev/null
+++ b/projects/migrations/0004_auto_20160726_1931.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-26 16:31
+from __future__ import unicode_literals
+
+import datetime
+from django.db import migrations, models
+from django.utils.timezone import utc
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('projects', '0003_auto_20160725_1606'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='stage',
+ options={'ordering': ['pos'], 'verbose_name': 'Этап', 'verbose_name_plural': 'Этапы'},
+ ),
+ migrations.AlterField(
+ model_name='stage',
+ name='created',
+ field=models.DateTimeField(default=datetime.datetime(2016, 7, 26, 16, 31, 5, 738741, tzinfo=utc)),
+ ),
+ ]
diff --git a/templates/home.html b/templates/home.html
index de9778e..bc6c7a9 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -6,14 +6,7 @@
{% include 'partials/header.html' %}
-{# {% url "password_reset_recover" %}#}
Основная задача сайта
-
-
- Authed? {{ request.user.is_authenticated }}
- {{ request.user }} ({{ request.user.pk }})
- {{ request.user.groups.all }}
-
diff --git a/templates/partials/base.html b/templates/partials/base.html
index 0d72d28..09ff0fb 100644
--- a/templates/partials/base.html
+++ b/templates/partials/base.html
@@ -31,10 +31,19 @@
{% if messages %}
{% for message in messages %}
- {{ message | safe }}
+ {{ message|safe }}
{% endfor %}
{% endif %}
+
+ {{ request.user }}
+
+ {% if request.user.is_authenticated %}
+ PK: {{ request.user.pk }}
+ Groups: {{ request.user.groups.all }}
+ {% endif %}
+
+
{% block content %}{% endblock %}
@@ -50,6 +59,7 @@
+
diff --git a/users/admin.py b/users/admin.py
index 1d81876..1890f01 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
-from .models import User, Team, ContractorFinancialInfo, ContractorResume, ContractorResumeFiles
+from .models import User, Team, UserFinancialInfo, ContractorResume, ContractorResumeFiles
class UserAdmin(admin.ModelAdmin):
@@ -11,7 +11,7 @@ class UserAdmin(admin.ModelAdmin):
return ', '.join(g.name for g in obj.groups.all())
admin.site.register(User, UserAdmin)
-admin.site.register(ContractorFinancialInfo)
+admin.site.register(UserFinancialInfo)
admin.site.register(Team)
admin.site.register(ContractorResume)
admin.site.register(ContractorResumeFiles)
diff --git a/users/forms.py b/users/forms.py
index 0812d8f..7a4f24b 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -3,7 +3,7 @@ from django.forms import ModelForm
import itertools
import pydash as _; _.map = _.map_; _.filter = _.filter_
-from .models import User, ContractorFinancialInfo
+from .models import User, UserFinancialInfo
from common.models import Location
from projects.models import Project, Realty, BuildingClassfication, ConstructionType
from specializations.models import Specialization
@@ -131,7 +131,7 @@ class CustomerProfileProjectRealtyForm(forms.Form):
)
-class ContractorFinancicalInfoForm(ModelForm):
+class UserFinancicalInfoForm(ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['residency'].choices = self.fields['residency'].choices[1:]
@@ -141,7 +141,7 @@ class ContractorFinancicalInfoForm(ModelForm):
# self.fields['residency'].widget.choices = self.fields['residency'].choices
class Meta:
- model = ContractorFinancialInfo
+ model = UserFinancialInfo
fields = (
'fio',
diff --git a/users/migrations/0003_auto_20160726_1931.py b/users/migrations/0003_auto_20160726_1931.py
new file mode 100644
index 0000000..6ee662f
--- /dev/null
+++ b/users/migrations/0003_auto_20160726_1931.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-26 16:31
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0002_auto_20160725_1605'),
+ ]
+
+ operations = [
+ migrations.RenameModel(
+ old_name='ContractorFinancialInfo',
+ new_name='UserFinancialInfo',
+ ),
+ migrations.RemoveField(
+ model_name='user',
+ name='contractor_financial_info',
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='financial_info',
+ field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user', to='users.UserFinancialInfo'),
+ ),
+ ]
diff --git a/users/mixins.py b/users/mixins.py
index d31cc8f..6bf0e1b 100644
--- a/users/mixins.py
+++ b/users/mixins.py
@@ -3,7 +3,6 @@ from django.contrib import messages
class CheckForUserMixin(object):
-
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
pk = kwargs.get('pk')
diff --git a/users/models.py b/users/models.py
index 25e071f..3a819db 100644
--- a/users/models.py
+++ b/users/models.py
@@ -41,7 +41,7 @@ class CustomerUserManager(models.Manager):
return super().get_queryset().filter(groups__name='Заказчики')
-class ContractorFinancialInfo(models.Model):
+class UserFinancialInfo(models.Model):
RESIDENCIES = (
('russian_resident', 'Резидент РФ'),
('non_russian_resident', 'Нерезидент РФ'),
@@ -117,7 +117,6 @@ class User(AbstractBaseUser, PermissionsMixin):
)
avatar = models.ImageField(upload_to='users/avatars/', blank=True)
- contractor_financial_info = models.OneToOneField(ContractorFinancialInfo, related_name='contractor', blank=True, null=True)
contractor_resume = models.OneToOneField(ContractorResume, related_name='contractor', blank=True, null=True)
contractor_specializations = TreeManyToManyField(Specialization, related_name='contractors', blank=True)
contractor_status = models.CharField(default='free', max_length=20, choices=STATUSES)
@@ -126,6 +125,7 @@ class User(AbstractBaseUser, PermissionsMixin):
date_joined = models.DateTimeField(default=timezone.now)
date_of_birth = models.DateTimeField(null=True, blank=True)
email = models.EmailField(max_length=255, unique=True, db_index=True)
+ financial_info = models.OneToOneField(UserFinancialInfo, related_name='user', blank=True, null=True)
first_name = models.CharField(max_length=255, blank=True)
gender = models.CharField(max_length=30, choices=GENDERS, blank=True)
is_active = models.BooleanField(default=True)
diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html
index 0cdaa44..c04773f 100644
--- a/users/templates/contractor_profile.html
+++ b/users/templates/contractor_profile.html
@@ -1,6 +1,7 @@
{% extends 'partials/base.html' %}
-{% load staticfiles %}
+{% load projects_tags %}
+{% load specializtions_tags %}
{% load thumbnail %}
@@ -70,7 +71,7 @@
- {{ contractor.get_full_name }}[{{ contractor.username }}]
+ {{ contractor.get_full_name }} [{{ contractor.username }}]
Россия, Москва
На сайте 8 лет и 3 месяца
@@ -80,11 +81,9 @@
показать контакты
- {% load specializtions_tags %}
{% specialization_widget contractor.pk %}
- {% load projects_tags %}
{% ratings_widget contractor.pk %}
{% if contractor.cro %}
diff --git a/users/templates/contractor_profile_edit.html b/users/templates/contractor_profile_edit.html
index 2d733c7..197d047 100644
--- a/users/templates/contractor_profile_edit.html
+++ b/users/templates/contractor_profile_edit.html
@@ -15,19 +15,19 @@
{% load mptt_tags %}
{{ form.errors }}
-
-
-
-

-
-
-
-
+
+
+
+

+
+
+
+
ФИО:
diff --git a/users/templates/customer_profile_edit.html b/users/templates/customer_profile_edit.html
index 0432434..effa6ff 100644
--- a/users/templates/customer_profile_edit.html
+++ b/users/templates/customer_profile_edit.html
@@ -1,113 +1,126 @@
{% extends 'partials/base.html' %}
-{% load staticfiles %}
{% load thumbnail %}
{% block content %}
-{% include 'partials/header.html' %}
+ {% include 'partials/header.html' %}
+
-
- {% include 'partials/footer.html' %}
+
+ {% include 'partials/footer.html' %}
{% endblock %}
+
+
{% block js_block %}
-