From 4f325646474152c9e1b5f6ab8b094caf8565cf56 Mon Sep 17 00:00:00 2001 From: Slava Kyrachevsky Date: Fri, 20 Jan 2017 12:25:48 +0200 Subject: [PATCH] =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=BF=D0=B5=D1=80=D0=B5=D1=87=D0=BD=D0=B5?= =?UTF-8?q?=D0=BC=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D0=B9=20=D1=83=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- place_exposition/models.py | 5 +- place_exposition/urls.py | 63 +++++++++++++------ place_exposition/views.py | 21 +++++++ proj/urls.py | 2 +- templates/client/place/place_detail.html | 7 ++- .../client/place/place_exposition_list.html | 21 +++++++ 6 files changed, 96 insertions(+), 23 deletions(-) create mode 100644 templates/client/place/place_exposition_list.html diff --git a/place_exposition/models.py b/place_exposition/models.py index 472c8d48..f700cc5b 100644 --- a/place_exposition/models.py +++ b/place_exposition/models.py @@ -6,6 +6,7 @@ from django.db.models.signals import post_save, pre_save from django.utils.translation import ugettext as _ from functools import partial from django.conf import settings +from django.core.urlresolvers import reverse from functions.translate import fill_with_signal # from hvad.models import TranslatableModel, TranslatedFields, TranslationManager @@ -152,10 +153,12 @@ class PlaceExposition(TranslatableModel, ExpoMixin): titles = ' '.join([tr.main_title for tr in translations]) return names + ' ' + titles - def __unicode__(self): return self.lazy_translation_getter('name', unicode(self.pk)) + def get_absolute_url(self): + return reverse('place_detail', args=[self.url]) + def get_object_type(self): return _(u'Места') diff --git a/place_exposition/urls.py b/place_exposition/urls.py index c9b64235..5ee78d27 100644 --- a/place_exposition/urls.py +++ b/place_exposition/urls.py @@ -1,30 +1,57 @@ # -*- coding: utf-8 -*- -from django.conf.urls import include, patterns, url +from django.conf.urls import patterns, url from .views import ( - PlaceCityCatalog, - PlaceCountryCatalog, - PlaceDetail, - PlaceList, - PlacePhoto, - PlaceByCountry, - PlaceByCity, + PlaceCityCatalog, PlaceCountryCatalog, PlaceDetail, PlaceList, PlacePhoto, + PlaceByCountry, PlaceByCity, PlaceExpositionListView ) -urlpatterns = patterns('', - +urlpatterns = patterns( + '', url(r'^country/$', PlaceByCountry.as_view(), {'meta_id': 49}), - url(r'^country/(?P.*)/page/(?P\d+)/$', PlaceCountryCatalog.as_view(), {'meta_id': 49}), - url(r'^country/(?P.*)/$', PlaceCountryCatalog.as_view(), {'meta_id': 49}, name='place_country'), + url( + r'^country/(?P.*)/page/(?P\d+)/$', + PlaceCountryCatalog.as_view(), + {'meta_id': 49} + ), + url( + r'^country/(?P.*)/$', + PlaceCountryCatalog.as_view(), + {'meta_id': 49}, + name='place_country' + ), url(r'^city/$', PlaceByCity.as_view(), {'meta_id': 48}), - url(r'^city/(?P.*)/page/(?P\d+)/$', PlaceCityCatalog.as_view(), {'meta_id': 48}), - url(r'^city/(?P.*)/$', PlaceCityCatalog.as_view(), {'meta_id': 48}, name='place_city'), + url( + r'^city/(?P.*)/page/(?P\d+)/$', + PlaceCityCatalog.as_view(), + {'meta_id': 48} + ), + url( + r'^city/(?P.*)/$', + PlaceCityCatalog.as_view(), + {'meta_id': 48}, + name='place_city' + ), - url(r'^(?P.*)/photo/page/(?P\d+)/$', PlacePhoto.as_view(), {'meta_id': 91}), + url( + r'^(?P.*)/photo/page/(?P\d+)/$', + PlacePhoto.as_view(), + {'meta_id': 91} + ), url(r'^(?P.*)/photo/$', PlacePhoto.as_view(), {'meta_id': 91}), url(r'^page/(?P\d+)/$', PlaceList.as_view(), {'meta_id': 46}), - url(r'^(?P.*)/$', PlaceDetail.as_view(), {'meta_id': 47}), - url(r'^$', PlaceList.as_view(), {'meta_id':46}), - ) + url( + r'^(?P.*)/expositions/$', + PlaceExpositionListView.as_view(), + name='place_exposition_list' + ), + url( + r'^(?P.*)/$', + PlaceDetail.as_view(), + {'meta_id': 47}, + name='place_detail' + ), + url(r'^$', PlaceList.as_view(), {'meta_id': 46}), +) diff --git a/place_exposition/views.py b/place_exposition/views.py index 50cdfe7f..286c3262 100644 --- a/place_exposition/views.py +++ b/place_exposition/views.py @@ -230,3 +230,24 @@ class PlaceCityCatalog(PlaceCatalog): context = super(PlaceCityCatalog, self).get_context_data(**kwargs) context['city'] = str(self.kwargs['city'].id) return context + + +class PlaceExpositionListView(ListView): + """ + Представление перечня событий относительно места. + Переход на эту страницу происходит со страницы подробного просмотра + места, по ссылке "Все события" + """ + template_name = 'client/place/place_exposition_list.html' + + def get_object(self): + slug = self.kwargs.get('slug') + return get_object_or_404(PlaceExposition, url=slug) + + def get_queryset(self): + return self.get_object().exposition_place.all() + + def get_context_data(self, **kwargs): + ctx = super(PlaceExpositionListView, self).get_context_data(**kwargs) + ctx['object'] = self.get_object() + return ctx diff --git a/proj/urls.py b/proj/urls.py index f4615f22..2cb53165 100644 --- a/proj/urls.py +++ b/proj/urls.py @@ -72,7 +72,7 @@ urlpatterns += solid_i18n_patterns('', url(r'^sitemap\.xml$', views.index, {'sitemaps': sitemaps}), url(r'^sitemap-(?P
.+)\.xml$', views.sitemap, {'sitemaps': sitemaps}), url(r'^robots.txt$', Robot.as_view()), - url(r'^$', MainPageView.as_view()), + url(r'^$', MainPageView.as_view(), name='index'), url(r'^user-agreement/$', TermsofUse.as_view(), name='termsofuse'), url(r'^page/', include('core.simple_urls')), url(r'^theme/', include('theme.urls')), diff --git a/templates/client/place/place_detail.html b/templates/client/place/place_detail.html index 77054e12..923bf6de 100644 --- a/templates/client/place/place_detail.html +++ b/templates/client/place/place_detail.html @@ -1,5 +1,6 @@ {% extends 'base_catalog.html' %} -{% load i18n template_filters static %} +{% load i18n static %} +{% load template_filters %} {% block bread_scrumbs %}