diff --git a/proj/urls.py b/proj/urls.py index 0933af0e..836154ed 100644 --- a/proj/urls.py +++ b/proj/urls.py @@ -55,6 +55,7 @@ urlpatterns = patterns('', url(r'^', include('company.urls')), url(r'^', include('photoreport.urls')), url(r'^', include('article.urls')), + url(r'^specialist/', include("specialist_catalog.urls")), url(r'^country/', include('country.urls')), url(r'^city/', include('city.urls')), url(r'^organiser/', include('organiser.urls')), diff --git a/service/urls.py b/service/urls.py index 10efb29a..5b3055a5 100644 --- a/service/urls.py +++ b/service/urls.py @@ -4,7 +4,7 @@ from views import ServiceView, CallBackListView, VisitListView, TranslationListV ParticipationListView, RemoteListView,TicketsListView, Thanks urlpatterns = patterns('', - url(r'service/thanks/$', Thanks.as_view()), + url(r'service/thanks/$', Thanks.as_view(), name = "service_thanks"), url(r'service/com_rek/(?P.*)/(?P.*)/$', 'service.views.advertise'), url(r'service/com_rek/$', 'service.views.advertise'), url(r'service/(?P.*)/$', ServiceView.as_view()), diff --git a/service/views.py b/service/views.py index 9fbc0586..a88e3766 100644 --- a/service/views.py +++ b/service/views.py @@ -46,7 +46,6 @@ class ServiceView(MetadataMixin, FormView): def form_valid(self, form): order = form.save(commit=False) order.save() - #messages.success(self.request, _(u'Ваш запрос был успешно отправлен')) return HttpResponseRedirect(self.success_url) def get_context_data(self, **kwargs): diff --git a/specialist_catalog/admin_urls.py b/specialist_catalog/admin_urls.py index e80e6fb9..df5e4ea6 100644 --- a/specialist_catalog/admin_urls.py +++ b/specialist_catalog/admin_urls.py @@ -9,10 +9,12 @@ urlpatterns = patterns('', url(r'^specialist/delete/(?P\d{1,4})/$', SpecialistDeleteView.as_view(), name='specialist_delete'), url(r'^catalog/new/$', CatalogCreateView.as_view(), name='catalog_new'), url(r'^catalog/all/$', CatalogListView.as_view(), name='catalog_all'), + url(r'^catalog/city/$', CatalogCityView.as_view(), name='catalog_city'), + url(r'^catalog/country/$', CatalogCountryView.as_view(), name='catalog_country'), url(r'^catalog/edit/(?P\d{1,4})/$', CatalogUpdateView.as_view(), name='catalog_edit'), url(r'^catalog/delete/(?P\d{1,4})/$', CatalogDeleteView.as_view(), name='catalog_delete'), - url(r'^catalog/(?P\d{1,4})/add_feedback/$', FeedbackCreateView.as_view(), name='feedback_new'), + url(r'^catalog/(?P\d{1,4})/add_feedback/$', FeedbackCreateView.as_view(), name='feedback_new'), #url(r'^catalog/(?P\d{1,4})/feedbacks/$', FeedbackListView.as_view(), name='feedback_all'), - url(r'^catalog/(?P\d{1,4})/feedback/(?P\d{1,4})/$', FeedbackUpdateView.as_view(), name='feedback_edit'), + url(r'^catalog/(?P\d{1,4})/feedback/(?P\d{1,4})/$', FeedbackUpdateView.as_view(), name='feedback_edit'), url(r'^feedback/delete/(?P\d{1,4})/$', FeedbackDeleteView.as_view(), name='feedback_delete'), ) \ No newline at end of file diff --git a/specialist_catalog/forms.py b/specialist_catalog/forms.py index 026a6c3f..a96c43ce 100644 --- a/specialist_catalog/forms.py +++ b/specialist_catalog/forms.py @@ -23,13 +23,14 @@ class SpecialistCatalogForm(TranslatableModelForm): class Meta: model = SpecialistCatalog fields = ['price', 'currency', 'logo_preview', 'main_descr', 'place_photo', - 'specialists', 'city', 'country', 'type', 'title', 'benefits'] + 'specialists', 'city', 'country', 'type', 'title', 'benefits', 'big_cities'] widgets = { 'type': forms.Select(choices=(('1', 'Country'), ('2', 'City'))), 'city': forms.HiddenInput(attrs={'id': 'id_city'}), 'country': forms.Select(choices=country_choices, attrs={'id': 'id_country'}), 'main_descr': CKEditorWidget, 'benefits': CKEditorWidget, + 'big_cities': CKEditorWidget, } def save(self, commit=True): diff --git a/specialist_catalog/models.py b/specialist_catalog/models.py index 8c32eb9d..2d54cd4a 100644 --- a/specialist_catalog/models.py +++ b/specialist_catalog/models.py @@ -38,7 +38,8 @@ class SpecialistCatalog(TranslatableModel): translations = TranslatedFields( title=models.CharField(max_length=255, verbose_name=u"Заголовок"), main_descr=models.CharField(max_length=1000, verbose_name=u"Краткое описание"), - benefits=models.CharField(max_length=2000, verbose_name=u"Преимущества") + benefits=models.CharField(max_length=2000, verbose_name=u"Преимущества"), + big_cities=models.TextField(verbose_name=u"Крупные города") ) def __init__(self, *args, **kwargs): @@ -49,9 +50,9 @@ class SpecialistCatalog(TranslatableModel): def get_absolute_url(self): global _country, _city if self.type == _country: - return reverse_lazy('spec_catalog_country', tws(self.country.name)) + return reverse_lazy('spec_catalog_country', kwargs={'slug':tws(self.country.name)}) else: - return reverse_lazy('spec_catalog_city', tws(self.city.name)) + return reverse_lazy('spec_catalog_city', kwargs={'slug':tws(self.city.name)}) def save(self, *args, **kwargs): super(SpecialistCatalog, self).save(*args, **kwargs) @@ -81,6 +82,9 @@ class SpecialistCatalog(TranslatableModel): self.is_new = False return self + def __unicode__(self): + return self.title + class Feedback(models.Model): company = models.CharField(max_length=255, verbose_name=u"Название компании") @@ -89,4 +93,7 @@ class Feedback(models.Model): logo = models.ImageField(verbose_name=u"Логотип компании", upload_to='specialist_catalog/feedback_logo/', blank=True) catalog = models.ForeignKey(SpecialistCatalog, verbose_name=u"Страница") + def __unicode__(self): + return "Feedback from %s" % self.company + diff --git a/specialist_catalog/urls.py b/specialist_catalog/urls.py index e4fb7c7b..47f45dd5 100644 --- a/specialist_catalog/urls.py +++ b/specialist_catalog/urls.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- from django.conf.urls import url, patterns -from .views import * +from .views import CatalogDetailedCityView, CatalogDetailedCountryView -urlpaterns = patterns('', +urlpatterns = patterns('', + url(r'^city/(?P.*)/$', CatalogDetailedCityView.as_view(), name="spec_catalog_city"), + url(r'^country/(?P.*)/$', CatalogDetailedCountryView.as_view(), name="spec_catalog_country"), ) \ No newline at end of file diff --git a/specialist_catalog/views.py b/specialist_catalog/views.py index 01382c7c..0dd43edb 100644 --- a/specialist_catalog/views.py +++ b/specialist_catalog/views.py @@ -1,9 +1,17 @@ # -*- coding: utf-8 -*- -from django.views.generic import CreateView, UpdateView, DeleteView, ListView, DetailView +from django.views.generic import CreateView, UpdateView, DeleteView, ListView, FormView, DetailView +from django.views.generic.detail import SingleObjectMixin from .forms import * from django.core.urlresolvers import reverse_lazy from django.conf import settings from django.shortcuts import get_object_or_404 +from service.order_forms import TranslationForm +from django.http import HttpResponseRedirect + + +# =========== ADMIN VIEWS =========== + +# Specialist views class SpecialistCreateView(CreateView): @@ -37,6 +45,9 @@ class SpecialistDeleteView(DeleteView): success_url = reverse_lazy("specialist_all") +# Catalog views + + class CatalogCreateView(CreateView): form_class = SpecialistCatalogForm model = SpecialistCatalog @@ -50,6 +61,26 @@ class CatalogListView(ListView): paginate_by = settings.ADMIN_PAGINATION +class CatalogCityView(ListView): + model = SpecialistCatalog + template_name = 'admin/specialist/catalog_all.html' + paginate_by = settings.ADMIN_PAGINATION + + def get_queryset(self): + qs = super(CatalogCityView, self).get_queryset() + return qs.filter(type=2) + + +class CatalogCountryView(ListView): + model = SpecialistCatalog + template_name = 'admin/specialist/catalog_all.html' + paginate_by = settings.ADMIN_PAGINATION + + def get_queryset(self): + qs = super(CatalogCountryView, self).get_queryset() + return qs.filter(type=1) + + class CatalogUpdateView(UpdateView): form_class = SpecialistCatalogForm model = SpecialistCatalog @@ -69,6 +100,9 @@ class CatalogDeleteView(DeleteView): success_url = reverse_lazy("catalog_all") +# Feedback views + + class FeedbackCreateView(CreateView): form_class = FeedbackForm model = Feedback @@ -76,14 +110,9 @@ class FeedbackCreateView(CreateView): success_url = reverse_lazy("catalog_all") def get_initial(self): - catalog = get_object_or_404(SpecialistCatalog, pk=self.kwargs.get('pk')) + catalog = get_object_or_404(SpecialistCatalog, pk=self.kwargs.get('catalog_pk')) return {'catalog': catalog} -# class FeedbackListView(ListView): -# model = Feedback -# template_name = 'admin/specialist/feedback_all.html' -# paginate_by = settings.ADMIN_PAGINATION - class FeedbackUpdateView(UpdateView): form_class = FeedbackForm @@ -92,10 +121,74 @@ class FeedbackUpdateView(UpdateView): success_url = reverse_lazy("catalog_all") def get_initial(self): - catalog = get_object_or_404(SpecialistCatalog, pk=self.kwargs.get('id')) + catalog = get_object_or_404(SpecialistCatalog, pk=self.kwargs.get('catalog_pk')) return {'catalog': catalog} + class FeedbackDeleteView(DeleteView): model = Feedback template_name = 'admin/specialist/feedback_confirm_delete.html' success_url = reverse_lazy("catalog_all") + + +# class FeedbackListView(ListView): +# model = Feedback +# template_name = 'admin/specialist/feedback_all.html' +# paginate_by = settings.ADMIN_PAGINATION + +# ========= CLIENT VIEWS ============ + + +class CatalogDetailedCityView(SingleObjectMixin, FormView): + model = SpecialistCatalog + form_class = TranslationForm + template_name = "client/specialist_catalog/catalog_detailed.html" + success_url = reverse_lazy("service_thanks") + + def get_object(self, queryset=None): + obj = self.model.objects.language().get(city__url=self.kwargs.get('slug')) + self.object = obj + return obj + + def get_context_data(self, **kwargs): + self.get_object() + context = super(CatalogDetailedCityView, self).get_context_data(**kwargs) + context['object'] = self.object + return context + + def form_valid(self, form): + order = form.save(commit=False) + order.save() + return HttpResponseRedirect(self.success_url) + + def get_initial(self): + obj = self.get_object() + return {'country':obj.country.name, 'city':obj.city.name} + + +class CatalogDetailedCountryView(SingleObjectMixin, FormView): + model = SpecialistCatalog + form_class = TranslationForm + template_name = "client/specialist_catalog/catalog_detailed.html" + success_url = reverse_lazy("service_thanks") + + + def get_object(self, queryset=None): + obj = self.model.objects.language().get(country__url=self.kwargs.get('slug')) + self.object = obj + return obj + + def get_context_data(self, **kwargs): + self.get_object() + context = super(CatalogDetailedCountryView, self).get_context_data(**kwargs) + context['object'] = self.object + return context + + def form_valid(self, form): + order = form.save(commit=False) + order.save() + return HttpResponseRedirect(self.success_url) + + def get_initial(self): + obj = self.get_object() + return {'country':obj.country.name} \ No newline at end of file diff --git a/templates/admin/specialist/catalog_all.html b/templates/admin/specialist/catalog_all.html index 73c42069..e249848c 100644 --- a/templates/admin/specialist/catalog_all.html +++ b/templates/admin/specialist/catalog_all.html @@ -12,8 +12,9 @@   Заголовок - Тип + {% if request.path == "/admin/specialist_catalog/catalog/city/" %}Город{% elif request.path == "/admin/specialist_catalog/catalog/country/" %}Страна{% else %}Страна/Город{% endif %} Количество специалистов + Link   @@ -26,8 +27,9 @@ {% endthumbnail %} {{ item.title }} - {% if item.type == 1%}Страна{% else %}Город{% endif %} + {% if item.type == 1%}{{ item.country.name }}{% else %}{{ item.city.name }}{% endif %} {{ item.specialists.count }} + Заценить Изменить diff --git a/templates/admin/specialist/catalog_new.html b/templates/admin/specialist/catalog_new.html index 024a2911..266a9dfe 100644 --- a/templates/admin/specialist/catalog_new.html +++ b/templates/admin/specialist/catalog_new.html @@ -51,6 +51,14 @@ {{ form.benefits.errors }} + {# big_cities #} +
+ +
+ {{ form.big_cities }} + {{ form.big_cities.errors }} +
+
{# price #}
@@ -156,7 +164,7 @@ {{ item.company }} {{ item.text }} - + Изменить @@ -189,7 +197,7 @@ {% endwith %} {% elif object.id %} Отзывов еще нет, - + Добавить {% endif %} {% endblock %} diff --git a/templates/client/specialist_catalog/catalog_detailed.html b/templates/client/specialist_catalog/catalog_detailed.html new file mode 100644 index 00000000..b0c079da --- /dev/null +++ b/templates/client/specialist_catalog/catalog_detailed.html @@ -0,0 +1,326 @@ +{% extends "client/base_catalog.html" %} +{% load static %} +{% load thumbnail %} +{% load i18n %} + +{% block head_scripts %} + +{% endblock %} + +{% block page_body%} +
+ +
+ +
+ + +
+
+
{{ object.title }}
+
+ +
+ {{ object.main_descr }} +
+
+ +
+ +{# #} +
+ {% thumbnail object.place_photo "957x400" crop="center" as im %} + + {% endthumbnail %} +
+ +{# #} +{#
#} +{# #} +{# #} +{#
#} +{# #} +{#
#} +
+ +
+
+ {{ object.big_cities }} +
+

Крупные города:

+ {{ object.big_cities }} +
+ +
+ +
+
+

Коротко о наших преимуществах:

+
+ {{ object.benefits|safe }} +
+
+
+ +{# ----------------------------------------- FORM ----------------------------------------------#} +
+
{% csrf_token %} + +
+ +
+ +
{% trans 'Информация о переводе' %}
+ +
+ +
+ {{ form.languages }} + +
+ +
+ {{ form.themes }} + + +
+
+ +
+ +
+ {{ form.days }} {% trans 'дней' %} +
+ +
+ {{ form.hours }} {% trans 'часов в день' %} +
+
+ +
+ +
+
+
+ + {{ form.fr }} +
+ {{ form.fr.errors }} + +
+
+
+ + {{ form.to }} +
+ {{ form.to.errors }} + +
+
+
+
+
+ +
+ +
+ +
+ +
{% trans 'Ваши контактные данные' %}
+ {% if not object %} +
+
+ {{ form.event }} +
+ {{ form.event.errors }} + +
+
+
+ {% endif %} + +
+
+ {{ form.person_inf }} +
+ {{ form.person_inf.errors }} + +
+
+
+ +
+
+ {{ form.country }} +
+ {{ form.country.errors }} + +
+
+ +
+ {{ form.city }} +
+ {{ form.city.errors }} + +
+
+
+ +
+
+ {{ form.phone }} +
+ {{ form.phone.errors }} + +
+
+ +
+ {{ form.person }} +
+ {{ form.person.errors }} + +
+
+
+ +
+ +
+ +
+ +
+
+
+ +
+
+
+ +
+ +
+
+{# ----------------------------------------- END FORM -------------------------------------------#} + +
+
+
+
+
+
от {{ object.price }} {{ object.currency }} / день
+ +
+
+
+
+
+ + + + +
+ {% if request.GET.debug == '1' %} + + {% else %} + + {% endif %} + + + + + + {% with object.specialists.all as specialists %} + {% if specialists %} +
+
Наши специалисты
+ + + +
+ {% endif %} + {% endwith %} + +
+ {% with object.feedback_set.all as feedbacks %} + {% if feedbacks %} +
+ +
+
Отзывы клиентов:
+
+ {% for feedback in feedbacks %} +
+
+ +
+ {% thumbnail feedback.logo "100x100" crop="center" as im %} + + {% endthumbnail %} +
+
+
+
+
{{ feedback.company }}
+
+
+ +
{{ feedback.name }}
+ +
+ {{ feedback.text }} +
+
+ +
+
+ {% endfor %} +
+
+ +
+ {% endif %} + {% endwith %} + +
+ +{% endblock %} \ No newline at end of file