diff --git a/archilance/settings/prod.py b/archilance/settings/prod.py index f80dd39..b961979 100644 --- a/archilance/settings/prod.py +++ b/archilance/settings/prod.py @@ -15,4 +15,5 @@ DATABASES = { DEBUG = True TEMPLATE_DEBUG = True -SECRET_KEY = 'vb6@b9zj7^f!^+x*e8=e!oundyu1!e*&0i(3gu2xwo4%fx4h&n' \ No newline at end of file +THUMBNAIL_DEBUG = True +SECRET_KEY = 'vb6@b9zj7^f!^+x*e8=e!oundyu1!e*&0i(3gu2xwo4%fx4h&n' diff --git a/common/templatetags/common_tags.py b/common/templatetags/common_tags.py index fed04fa..6c0ed77 100644 --- a/common/templatetags/common_tags.py +++ b/common/templatetags/common_tags.py @@ -11,6 +11,25 @@ register = template.Library() # def inspect(context, obj): # return {'obj': pformat(obj.__dict__)} +@register.simple_tag +def morph_words(number, words): + words = words.split(',') + try: + if type(number) == str: + number = int(number) + except Exception: + return words[2] + + if number > 10: + number %= 10 + + if number == 1: + return words[0] + elif 1 < number < 5: + return words[1] + else: + return words[2] + @register.filter def inspect(obj): diff --git a/projects/models.py b/projects/models.py index 96c8551..4b94a71 100644 --- a/projects/models.py +++ b/projects/models.py @@ -131,6 +131,18 @@ class Answer(models.Model): content_type = models.ForeignKey(ContentType, limit_choices_to=Q(app_label='users', model='user') | Q(app_label='users', model='team')) object_id = models.IntegerField() author = GenericForeignKey('content_type', 'object_id') + + def get_first_message(self): + return self.messages.first().text + + def get_term_type_labels(self): + term_type_labels = { + 'hour': 'час,часа,часов', + 'day': 'день,дня,дней', + 'month': 'месяц,мксяца,месяцев', + 'project': 'проект,проект,проект' + } + return term_type_labels.get(self.term_type) def __str__(self): return "{author}'s answer ({id})".format(author=type(self.author).__name__, id=self.pk) @@ -161,6 +173,7 @@ class AnswerMessage(models.Model): return str(self.pk) class Meta: + ordering = ['created'] verbose_name = 'Отклики на проекты -- переписка' verbose_name_plural = 'Отклики на проекты -- переписки' @@ -261,7 +274,7 @@ class Portfolio(models.Model): def get_cover(self): photo = self.photos.first() - return photo and photo.img.url + return photo and photo.img class PortfolioPhoto(models.Model): diff --git a/projects/templates/comparison.html b/projects/templates/comparison.html index 8e4b07e..2d68634 100644 --- a/projects/templates/comparison.html +++ b/projects/templates/comparison.html @@ -1,6 +1,7 @@ {% extends 'partials/base.html' %} {% load staticfiles %} +{% load i18n %} {% block content %} {% include 'partials/header.html' %} @@ -8,7 +9,8 @@
-

Сравнение кандидатов по проекту

+

+ Сравнение кандидатов по проекту

@@ -38,22 +40,26 @@ {{ cand.answer.budget }} - {{ cand.answer.term }}
{{ cand.answer.term_type }} + + {{ cand.answer.term }}
+ {% morph_words cand.answer.term cand.answer.get_term_type_labels %} + - +
    -
  • 0
  • + +
  • {{ cand.answer.author.rating }}
  • +
  • - +0 - 0 - - 0 + +0 0 - 0
  • - {% if cand.answer.contractor.cro %} + + {% if cand.answer.author.cro %}
  • СРО
  • @@ -63,7 +69,9 @@ 0
    - Готов работать по безопасной сделке + {% if cand.answer.secure_deal_only %} + Готов работать по безопасной сделке + {% endif %} @@ -79,8 +87,9 @@
    {% csrf_token %}
    - +
    +
diff --git a/users/models.py b/users/models.py index 2b3a9a2..8adb8c4 100644 --- a/users/models.py +++ b/users/models.py @@ -142,6 +142,15 @@ class User(AbstractBaseUser, PermissionsMixin): username = models.CharField(max_length=50, unique=True) website = models.CharField(max_length=255, blank=True) + def get_location(self): + if self.location: + if self.location.level == 3: + return self.location.parent.parent.name + ', ' + self.location.name + else: + return None + else: + return None + @property def is_staff(self): return self.is_superuser diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index f2a45f0..b831ce4 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -13,12 +13,11 @@
-{# {% thumbnail contractor.avatar "235x224" crop="center" as im %}#} -{# profile-image#} -{# {% endthumbnail %}#} - {% if contractor.avatar %} - profile-image + {% thumbnail contractor.avatar "235x224" crop="center" as im %} + profile-image + {% endthumbnail %} + {% else %} profile-image {% endif %} @@ -33,12 +32,7 @@ -
  • - - редактировать профиль - - -
  • + {% endif %} {% if contractor.pk != request.user.pk and request.user.is_contractor %} @@ -76,13 +70,14 @@

    {{ contractor.get_full_name }} [{{ contractor.username }}]

    -

    Россия, Москва

    - +

    {{ contractor.get_location }}

    + {% if contractor.contractor_status == 'free' %}
    Свободен
    + {% else %} +
    Занят
    {% endif %} - показать контакты
    @@ -99,6 +94,7 @@ {% endif %}
    +
    +