diff --git a/assets/index.js b/assets/index.js index 31c3590..001c768 100644 --- a/assets/index.js +++ b/assets/index.js @@ -45,38 +45,55 @@ var specSelectOptions = { } } -var $specSelects = $('.-spec-select') -$specSelects.select2(specSelectOptions) +$('.-spec-select-container').each(function(i, container) { + var $container = $(container) + var $specSelects = $(container).find('.-spec-select') + var $chosenSpecId = $container.find('.-chosen-spec-id').first() + + var $specSelect1 = $container.find('.-spec-select-level-1').first() + var $specSelect2 = $container.find('.-spec-select-level-2').first() + var $specSelect3 = $container.find('.-spec-select-level-3').first() + var $specSelect4 = $container.find('.-spec-select-level-4').first() + + var specSelects = [$specSelect1, $specSelect2, $specSelect3, $specSelect4] + + + $specSelects.select2(specSelectOptions) + + var chosenSpecId = $chosenSpecId.val() + + if (chosenSpecId) + updateSpecializationWidgets(chosenSpecId, $container, $chosenSpecId, specSelects) + + $specSelects.on('change', function($evt) { + var specId = $evt.added ? $evt.added.id : null + updateSpecializationWidgets(specId, $container, $chosenSpecId, specSelects) + }) +}) + + + + -var chosenSpecId = $('#chosenSpecId').val() -if (chosenSpecId) - updateSpecializationWidgets(chosenSpecId) -$specSelects.on('change', function($evt) { - updateSpecializationWidgets($evt.added ? $evt.added.id : null) -}) -var $specSelect1 = $('.-spec-select-level-1') -var $specSelect2 = $('.-spec-select-level-2') -var $specSelect3 = $('.-spec-select-level-3') -var $specSelect4 = $('.-spec-select-level-4') -function updateSpecializationWidgets(specId) { +function updateSpecializationWidgets(specId, $container, $chosenSpecId, specSelects) { return getSpecializationTree(specId).then(function(specs) { var specLevel1 = specs.specLevel1 var specLevel2 = specs.specLevel2 var specLevel3 = specs.specLevel3 var specLevel4 = specs.specLevel4 - $specSelect1.select2('data', specLevel1 ? {id: specLevel1.id, text: specLevel1.name, origItem: specLevel1} : null) - $specSelect2.select2('data', specLevel2 ? {id: specLevel2.id, text: specLevel2.name, origItem: specLevel2} : null) - $specSelect3.select2('data', specLevel3 ? {id: specLevel3.id, text: specLevel3.name, origItem: specLevel3} : null) - $specSelect4.select2('data', specLevel4 ? {id: specLevel4.id, text: specLevel4.name, origItem: specLevel4} : null) + specSelects[0].select2('data', specLevel1 ? {id: specLevel1.id, text: specLevel1.name, origItem: specLevel1} : null) + specSelects[1].select2('data', specLevel2 ? {id: specLevel2.id, text: specLevel2.name, origItem: specLevel2} : null) + specSelects[2].select2('data', specLevel3 ? {id: specLevel3.id, text: specLevel3.name, origItem: specLevel3} : null) + specSelects[3].select2('data', specLevel4 ? {id: specLevel4.id, text: specLevel4.name, origItem: specLevel4} : null) - $('#chosenSpecId').val(specId) + $chosenSpecId.val(specId) }) } diff --git a/projects/models.py b/projects/models.py index 23fc0c9..fe202ec 100644 --- a/projects/models.py +++ b/projects/models.py @@ -4,6 +4,7 @@ from django.db import models from django.db.models import Q from django.utils import timezone from mptt.models import TreeForeignKey +import pydash as _; _.map = _.map_; _.filter = _.filter_ from users.models import User, Team from specializations.models import Specialization @@ -76,7 +77,7 @@ class Project(models.Model): ('trashed', 'В корзине'), ('deleted', 'Удален'), ) - + budget = models.DecimalField(max_digits=10, decimal_places=0) budget_by_agreement = models.BooleanField(default=False) created = models.DateTimeField(default=timezone.now) @@ -104,6 +105,9 @@ class Project(models.Model): def secure_deal(self): return self.deal_type == 'secure_deal' + + def get_team_answers(self): + return _.filter(self.answers.all(), lambda a: isinstance(a.author, Team)) class ProjectFile(models.Model): diff --git a/projects/templates/customer_project_create.html b/projects/templates/customer_project_create.html index b55e31c..99ebf5d 100644 --- a/projects/templates/customer_project_create.html +++ b/projects/templates/customer_project_create.html @@ -81,7 +81,7 @@
--> -
+
@@ -98,7 +98,7 @@
- +
Бюджет {{ form.budget.errors.as_text }}
diff --git a/projects/templates/customer_project_edit.html b/projects/templates/customer_project_edit.html index ff9b69d..fac5262 100644 --- a/projects/templates/customer_project_edit.html +++ b/projects/templates/customer_project_edit.html @@ -90,7 +90,7 @@
-->
-
+
@@ -107,7 +107,7 @@
- +
Бюджет {{ form.budget.errors.as_text }}
diff --git a/projects/templates/project_filter.html b/projects/templates/project_filter.html index 42d8861..9cdbebe 100644 --- a/projects/templates/project_filter.html +++ b/projects/templates/project_filter.html @@ -31,7 +31,8 @@
Специализации
-
+ +
@@ -45,7 +46,7 @@
- +
@@ -182,9 +183,6 @@
  • Объект "{{ proj.realty.name }}"
  • -
  • - 0 ответ от имени группы -
  • {{ proj.text }}

    diff --git a/templates/test.html b/templates/test.html index 7c70c43..4c81e6d 100644 --- a/templates/test.html +++ b/templates/test.html @@ -3,21 +3,8 @@ {% block content %}
    -
    -

    Add a file...

    - - +
    +

    Hello there

    diff --git a/users/templates/contractor_office_open_projects.html b/users/templates/contractor_office_open_projects.html index 97de5d7..dd29361 100644 --- a/users/templates/contractor_office_open_projects.html +++ b/users/templates/contractor_office_open_projects.html @@ -43,9 +43,6 @@
  • Объект "{{ proj.realty.name }}"
  • -
  • - 0 ответ от имени группы -
  • diff --git a/users/templates/contractor_office_open_projects_archive.html b/users/templates/contractor_office_open_projects_archive.html index 27b2fdd..a410993 100644 --- a/users/templates/contractor_office_open_projects_archive.html +++ b/users/templates/contractor_office_open_projects_archive.html @@ -43,9 +43,6 @@
  • Объект "{{ proj.realty.name }}"
  • -
  • - 0 ответ от имени группы -
  • diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index 706acdb..8bf230b 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -14,10 +14,9 @@
    {% if contractor.avatar %} - {% thumbnail contractor.avatar "235x224" crop="center" as im %} - profile-image - {% endthumbnail %} - + {% thumbnail contractor.avatar "235x224" crop="center" as im %} + profile-image + {% endthumbnail %} {% else %} profile-image {% endif %} diff --git a/users/templates/customer_profile_open_projects.html b/users/templates/customer_profile_open_projects.html index 8cbab81..8542f1f 100644 --- a/users/templates/customer_profile_open_projects.html +++ b/users/templates/customer_profile_open_projects.html @@ -48,7 +48,7 @@
    • Объект "{{ proj.realty.name }}"
    • -
    • 0 ответ от имени группы
    • +
    • {{ proj.get_team_answers|length }} ответ от имени группы
      diff --git a/users/templates/partials/customer_profile_info_block.html b/users/templates/partials/customer_profile_info_block.html index dc0cb45..e2a2769 100644 --- a/users/templates/partials/customer_profile_info_block.html +++ b/users/templates/partials/customer_profile_info_block.html @@ -1,10 +1,15 @@ {% load specializtions_tags %} +{% load thumbnail %} + +
      {% if customer.avatar %} - profile-image + {% thumbnail customer.avatar "235x224" crop="center" as im %} + profile-image + {% endthumbnail %} {% else %} profile-image {% endif %} diff --git a/users/templates/user_financial_info_edit.html b/users/templates/user_financial_info_edit.html index 60b806a..f52807e 100644 --- a/users/templates/user_financial_info_edit.html +++ b/users/templates/user_financial_info_edit.html @@ -1,6 +1,8 @@ {% extends 'partials/base.html' %} {% load thumbnail %} + + {% block content %} {% include 'partials/header.html' %} @@ -21,7 +23,9 @@
      {% if form.avatar.value %} - profile-image + {% thumbnail form.avatar.value "235x224" crop="center" as im %} + profile-image + {% endthumbnail %} {% else %} profile-image {% endif %} diff --git a/users/templates/user_profile_edit.html b/users/templates/user_profile_edit.html index 04016ae..08d8069 100644 --- a/users/templates/user_profile_edit.html +++ b/users/templates/user_profile_edit.html @@ -23,7 +23,9 @@
      {% if form.avatar.value %} - profile-image + {% thumbnail form.avatar.value "235x224" crop="center" as im %} + profile-image + {% endthumbnail %} {% else %} profile-image {% endif %} diff --git a/users/urls.py b/users/urls.py index cd6bf23..c71597a 100755 --- a/users/urls.py +++ b/users/urls.py @@ -3,19 +3,19 @@ from django.conf.urls import include from django.contrib.auth.views import login, logout from .views import ( + contractor_resumefile_create, ContractorFilterView, ContractorOfficeDetailView, + ContractorOfficeOpenProjectsView, ContractorProfileDetailView, + ContractorResumeUpdateView, CustomerProfileCurrentProjectsView, CustomerProfileOpenProjectsView, CustomerProfileReviewsView, CustomerProfileTrashedProjectsView, + TeamCreateView, UserFinancialInfoEditView, UserProfileEditView, - TeamCreateView, - ContractorResumeUpdateView, - ContractorOfficeOpenProjectsView, - contractor_resumefile_create, )