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 945cf1ab..77fa4715 100644 --- a/templates/client/place/place_detail.html +++ b/templates/client/place/place_detail.html @@ -213,7 +213,7 @@

{% trans 'Список событий' %} - {% trans 'Все события' %} + {% trans 'Все события' %}