diff --git a/archilance/mixins.py b/archilance/mixins.py index f55cc5e..0a80895 100644 --- a/archilance/mixins.py +++ b/archilance/mixins.py @@ -17,7 +17,8 @@ class BaseMixin(ContextMixin): c['domain'] = Site.objects.get_current().domain - c['TEMPLATE_DEBUG'] = settings.TEMPLATE_DEBUG + c['TEMPLATE_DEBUG'] = getattr(settings, 'TEMPLATE_DEBUG', None) + c['TESTING'] = getattr(settings, 'TESTING', None) return c diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 5220551..b391b4b 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -14,7 +14,6 @@ SECRET_KEY = 'vb6@b9zj7^f!^+x*e8=e!oundyu1!e*&0i(3gu2xwo4%fx4h&n' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -TEMPLATE_DEBUG = True # Show debug info in templates. See `projects/templates/project_filter.html` ALLOWED_HOSTS = [] diff --git a/archilance/settings/dev.py b/archilance/settings/dev.py index a3da647..b095fbd 100644 --- a/archilance/settings/dev.py +++ b/archilance/settings/dev.py @@ -1,8 +1,5 @@ from .base import * -# AUTH_PASSWORD_VALIDATORS = [] - -# INSTALLED_APPS += ['debug_toolbar',] try: from .local import * except ImportError: diff --git a/archilance/settings/prod.py b/archilance/settings/prod.py index 4acb948..62f15c6 100644 --- a/archilance/settings/prod.py +++ b/archilance/settings/prod.py @@ -14,7 +14,6 @@ DATABASES = { DEBUG = True -TEMPLATE_DEBUG = True THUMBNAIL_DEBUG = True SECRET_KEY = 'vb6@b9zj7^f!^+x*e8=e!oundyu1!e*&0i(3gu2xwo4%fx4h&n' diff --git a/archilance/urls.py b/archilance/urls.py index 8c7bfa5..c50d9fd 100644 --- a/archilance/urls.py +++ b/archilance/urls.py @@ -5,7 +5,7 @@ from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views.generic import TemplateView -from .views import HomeTemplateView, TestChatTemplateView +from .views import HomeTemplateView, TestChatTemplateView, TestView from wallets.views import TmpCheckOrderView, TmpPaymentAvisoView from wagtail.wagtailadmin import urls as wagtailadmin_urls @@ -17,7 +17,7 @@ urlpatterns = [ url('', include('social.apps.django_app.urls', namespace='social')), url(r'^chattest/$', TestChatTemplateView.as_view()), url(r'^work_sell/', include('work_sell.urls')), - url(r'^test/$', TemplateView.as_view(template_name='test.html'), name='test'), + url(r'^test/$', TestView.as_view(), name='test'), url(r'^projects/', include('projects.urls')), url(r'^reviews/', include('reviews.urls')), url(r'^wallets/', include('wallets.urls')), diff --git a/archilance/views.py b/archilance/views.py index 6f4a147..963d02d 100644 --- a/archilance/views.py +++ b/archilance/views.py @@ -1,9 +1,15 @@ +from django.conf import settings +from django.contrib import messages +from django.core.exceptions import PermissionDenied from django.core.files.base import ContentFile -from django.shortcuts import render -from django.template.loader import render_to_string +from django.core.urlresolvers import reverse, reverse_lazy +from django.http import HttpResponseForbidden, JsonResponse, HttpResponseRedirect, HttpResponse, Http404 +from django.shortcuts import render, get_object_or_404, redirect from django.views.generic import TemplateView, View +from pprint import pprint, pformat import logging +from .mixins import BaseMixin from chat.models import Documents from common.models import MainPage, PrintDocuments from projects.models import Order @@ -11,12 +17,16 @@ from users.models import ContractorResumeFiles from work_sell.models import Picture -class HomeTemplateView(View): +class HomeTemplateView(BaseMixin, View): template_name = 'home.html' def get(self, request, *args, **kwargs): + context = self.get_context_data(**kwargs) + main_settings = MainPage.objects.get(pk=1) - return render(request, self.template_name, {'main_settings': main_settings}) + context['main_settings'] = main_settings + + return render(request, self.template_name, context) class TestChatTemplateView(View): @@ -36,3 +46,13 @@ class TestChatTemplateView(View): document.file = temp_file document.save() + +class TestView(BaseMixin, View): + template_name = 'test.html' + + def get(self, request, *args, **kwargs): + # context = self.get_context_data(**kwargs) + # context['foo'] = 'bar' + # return render(request, self.template_name, context) + + return redirect('projects:detail', pk=153) diff --git a/common/templatetags/common_tags.py b/common/templatetags/common_tags.py index 662f289..77c0a5c 100644 --- a/common/templatetags/common_tags.py +++ b/common/templatetags/common_tags.py @@ -115,4 +115,13 @@ def morph(number, words_string): return '%s %s' % (number, util.morph(number, words)) +@register.simple_tag +def fa_currency_classes(currency): + CURRENCIES = {'rur': 'rub', 'eur': 'eur', 'usd': 'usd'} + currency_class = CURRENCIES.get(currency) + + if currency_class: + return 'fa fa-%s' % currency_class + + # import code; code.interact(local=dict(globals(), **locals())) diff --git a/projects/models.py b/projects/models.py index 9e931d6..f3efa9a 100644 --- a/projects/models.py +++ b/projects/models.py @@ -270,8 +270,8 @@ class Stage(models.Model): class Candidate(models.Model): - answer = models.ForeignKey(Answer, related_name='candidates') - project = models.ForeignKey(Project, related_name='candidates') + answer = models.ForeignKey(Answer, related_name='candidates') # TODO: Swap to "OneToOneField" + project = models.ForeignKey(Project, related_name='candidates') # TODO: Remove this redundant field at all (we've got "candidate.answer.project") status = models.BooleanField(default=False) position = models.PositiveIntegerField(default=0) diff --git a/projects/templates/comparison.html b/projects/templates/comparison.html index da06d86..a73f3c2 100644 --- a/projects/templates/comparison.html +++ b/projects/templates/comparison.html @@ -33,14 +33,18 @@ {% for cand in object.candidates.all %} {{ cand.position }} + - {{ cand.answer.author.username }} + {% if cand.answer.author|class_name == 'User' %} + {{ cand.answer.author.get_full_name }} + {% elif cand.answer.author|class_name == 'Team' %} + {{ cand.answer.author.name }} + {% endif %} - {{ cand.answer.budget }} + {{ cand.answer.budget }} - {{ cand.answer.term }}
{% morph_words cand.answer.term cand.answer.get_term_type_labels %} @@ -90,8 +94,9 @@
{% csrf_token %}
+ -
+
diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 1801247..c13322c 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -19,7 +19,7 @@ {% if request.user.is_contractor %}
-

{{ project.budget|intcomma }}

+

{{ project.budget|intcomma }}

{% endif %} @@ -237,7 +237,7 @@

Цена: {{ answer.budget|intcomma }} - +

Срок: {{ answer.term }} {{ answer.get_currency_display }} {{ answer.get_term_type_display|decap }} @@ -563,7 +563,7 @@

Цена: {{ answer.budget|intcomma }} - +

Срок: {{ answer.term }} {{ answer.get_currency_display }} {{ answer.get_term_type_display|decap }} @@ -695,7 +695,7 @@

{% if answer.author|class_name == 'User' %} - {% ratings_widget answer.author.pk 'restList2' %} + {% ratings_widget answer.author.pk 'restList2' %} {% elif answer.author|class_name == 'Team'%} {% ratings_team_widget answer.author.pk 'restList2' %} {% endif %} @@ -719,7 +719,7 @@

Цена: {{ answer.budget|intcomma }} - +

Срок: {{ answer.term }} {{ answer.get_currency_display }} {{ answer.get_term_type_display|decap }} @@ -728,6 +728,12 @@

+ {% if TESTING %} + + Кандидат + + {% endif %} + {% if not project.order.contractor and not project.order.team %}
{% csrf_token %} @@ -867,7 +873,7 @@

Цена: {{ answer.budget|intcomma }} - +

Срок: {{ answer.term }} {{ answer.get_currency_display }} {{ answer.get_term_type_display|decap }} diff --git a/projects/templates/project_filter.html b/projects/templates/project_filter.html index 8c446cf..45fcbff 100644 --- a/projects/templates/project_filter.html +++ b/projects/templates/project_filter.html @@ -214,7 +214,7 @@

- {{ project.budget }} + {{ project.budget }}

- {{ contractor.contractor_resume.text | safe }} + {{ contractor.contractor_resume.text|safe }}
@@ -562,7 +562,7 @@ {% block js_block %}