diff --git a/.gitignore b/.gitignore index 77d3e39..b7f1121 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ env/ ar/ archilance/settings/local.py media/ +todo/ diff --git a/common/utils.py b/common/utils.py new file mode 100644 index 0000000..4a75d6a --- /dev/null +++ b/common/utils.py @@ -0,0 +1,9 @@ +from django.shortcuts import _get_queryset + +def get_or_none(klass, *args, **kwargs): + queryset = _get_queryset(klass) + + try: + return queryset.get(*args, **kwargs) + except queryset.model.DoesNotExist: + return None diff --git a/projects/__init__.py b/projects/__init__.py index e69de29..e03f848 100644 --- a/projects/__init__.py +++ b/projects/__init__.py @@ -0,0 +1 @@ +default_app_config = 'projects.apps.ProjectsConfig' diff --git a/projects/models.py b/projects/models.py index d0be358..81f6e51 100644 --- a/projects/models.py +++ b/projects/models.py @@ -188,6 +188,13 @@ class Portfolio(models.Model): verbose_name = 'Портфолио' verbose_name_plural = 'Портфолио' + def get_cover(self): + cover = None + all_photos = self.portfoliophoto_set.all() + if all_photos: + cover = all_photos[0].img + return cover + class PortfolioPhoto(models.Model): img = models.ImageField(upload_to='projects/portfolio') diff --git a/projects/templates/templatetags/ratings_widget.html b/projects/templates/templatetags/ratings_widget.html new file mode 100644 index 0000000..cf46dae --- /dev/null +++ b/projects/templates/templatetags/ratings_widget.html @@ -0,0 +1,14 @@ +
+ + diff --git a/projects/templatetags/__init__.py b/projects/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/projects/templatetags/projects_tags.py b/projects/templatetags/projects_tags.py new file mode 100644 index 0000000..59062b0 --- /dev/null +++ b/projects/templatetags/projects_tags.py @@ -0,0 +1,10 @@ +from django import template + +register = template.Library() + +@register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True) +def ratings_widget(context, user_id): + ratings = user_id + return { + 'ratings': ratings, + } diff --git a/projects/views.py b/projects/views.py index 2c875d4..cf98fdc 100644 --- a/projects/views.py +++ b/projects/views.py @@ -109,8 +109,9 @@ class ProjectView(BaseMixin, View): customer_template_name = 'customer_project_detail.html' def get(self, request, *args, **kwargs): + # import code; code.interact(local=dict(globals(), **locals())) if request.user.is_authenticated() and request.user.is_customer(): - project = get_object_or_404(request.user.projects, pk=kwargs.get('pk')) + project = get_object_or_404(Project, pk=kwargs.get('pk')) context = self.get_context_data(**_.merge({}, request.GET, kwargs)) context.update({'project': project}) @@ -180,7 +181,6 @@ class ContractorProjectAnswerView(BaseMixin, View): answer.project = project answer.save() order = Order.objects.create(project=project) - return HttpResponseRedirect(reverse('projects:detail', kwargs={'pk': project.pk})) @@ -239,7 +239,6 @@ class CustomerProjectDeleteView(View): project = form.cleaned_data.get('pk') project.state = 'deleted' project.save() - messages.info(req, 'Проект удалён навсегда') else: messages.info(req, 'Произошла ошибка:{msg}'.format(msg=pformat(form.errors)))
diff --git a/specializations/__init__.py b/specializations/__init__.py
index e69de29..f91e695 100644
--- a/specializations/__init__.py
+++ b/specializations/__init__.py
@@ -0,0 +1 @@
+default_app_config = 'specializations.apps.SpecializationConfig'
diff --git a/specializations/templates/templatetags/specializations_widget.html b/specializations/templates/templatetags/specializations_widget.html
new file mode 100644
index 0000000..89f66f0
--- /dev/null
+++ b/specializations/templates/templatetags/specializations_widget.html
@@ -0,0 +1,9 @@
+Специализации:
+ {% for spec in specializations %} +