diff --git a/archilance/util.py b/archilance/util.py index a77321a..0deaf48 100644 --- a/archilance/util.py +++ b/archilance/util.py @@ -66,6 +66,13 @@ def get_related_or_none(obj, attr): return rel +def has_related(obj, attr): + try: + return bool(getattr(obj, attr)) + except ObjectDoesNotExist: + return False + + def get_attr_or_none(klass, *args, attr=None, **kwargs): object = get_or_none(klass, *args, **kwargs) diff --git a/assets/js/chat.js b/assets/js/chat.js index 0d5dbda..10977ed 100644 --- a/assets/js/chat.js +++ b/assets/js/chat.js @@ -1,6 +1,6 @@ var SocketHandler = function () { domain = domain.replace(':' + port, ''); - var url = 'ws://' + domain + '/chat/' + userId + '/'; + var url = 'ws://' + domain + ':8888/chat/' + userId + '/'; var sock = new WebSocket(url); var intervalId; sock.onopen = function () { diff --git a/projects/forms.py b/projects/forms.py index e16d95c..c2a8977 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -213,10 +213,16 @@ class ProjectAnswerForm(forms.ModelForm): if self.answer_as_team: self.fields['secure_deal_only'].label = 'Работаем только по безопасной сделке' - try: members = self.request.user.team.contractors.all() - except Team.DoesNotExist: members = () + contractor = self.request.user + members = contractor.team.contractors.all() if util.has_related(contractor, 'team') else () - portfolios = Portfolio.objects.filter(user__pk__in=tuple(m.pk for m in members)) + # portfolios = [] + # portfolios.extend(contractor.portfolios.all()) + # + # for c in members: + # portfolios.extend(c.portfolios.all()) + + portfolios = Portfolio.objects.filter(user__pk__in=tuple(m.pk for m in itertools.chain((contractor,), members))) self.fields['portfolios'].queryset = portfolios else: diff --git a/projects/models.py b/projects/models.py index aa8c6b3..46c8aa4 100644 --- a/projects/models.py +++ b/projects/models.py @@ -18,10 +18,10 @@ CURRENCIES = ( ) TERM_TYPES = ( - ('day', 'За день'), - ('hour', 'За час'), - ('month', 'За месяц'), - ('project', 'За проект'), + ('day', 'день'), + ('hour', 'час'), + ('month', 'месяц'), + ('project', 'проект'), ) TERM_TYPE_MORPHS = { diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 2553141..4cdf3e9 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -24,7 +24,7 @@ {% endif %}
- {% endif %}
- - {% if answer.author|class_name == 'User' %} - {{ answer.author.get_full_name }} [{{ answer.author.username }}] - {% elif answer.author|class_name == 'Team' %} - {{ answer.author.name }} - {% endif %} -
+ {% if answer.author|class_name == 'User' %} + +
+ {% endif %}
+ + {{ answer.author.get_full_name }} [{{ answer.author.username }}] +
+ {% elif answer.author|class_name == 'Team' %} + +
+ {% endif %}
+
- {% endif %}
- - {% if answer.author|class_name == 'User' %} - {{ answer.author.get_full_name }} [{{ answer.author.username }}] - {% elif answer.author|class_name == 'Team' %} - {{ answer.author.name }} - {% endif %} -
+ {% if answer.author|class_name == 'User' %} + +
+ {% endif %}
+ + {{ answer.author.get_full_name }} [{{ answer.author.username }}] +
+ {% elif answer.author|class_name == 'Team' %} + +
+ {% endif %}
+