From edd92d4d6b4f9be039164c1e636efb4d36642b41 Mon Sep 17 00:00:00 2001 From: Alexander Burdeiny Date: Tue, 2 Aug 2016 17:33:51 +0300 Subject: [PATCH 1/2] =?UTF-8?q?1496:=20=D0=92=D0=BD=D0=B5=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BE=20=D1=81=D0=BE=20=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=D0=B9=D0=BF=D0=B0=20404=201497:=20=D0=92=D0=BD=D0=B5?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D0=BD=D0=BE=D0=B2=D0=BE=20=D1=81=D0=BE=20?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D0=B9=D0=BF=D0=B0=20seo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/views.py | 35 +++--- conference/urls.py | 102 +++++++++--------- exposition/urls.py | 100 ++++++++--------- meta/models.py | 12 +-- templates/client/article/news.html | 2 +- .../client/includes/place/place_object.html | 6 +- 6 files changed, 128 insertions(+), 129 deletions(-) diff --git a/accounts/views.py b/accounts/views.py index 1c2dbaea..1fc611ff 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -221,12 +221,7 @@ class ProfileCompanyView(TemplateView): return context -class UserView(MetadataMixin, TemplateView): - """ - display user information for another users - """ - template_name = 'client/accounts/user.html' - +class UserMixin(object): def get_user(self): url = self.kwargs.get('url') @@ -238,6 +233,14 @@ class UserView(MetadataMixin, TemplateView): self.kwargs['user_full_name'] = user.get_full_name() return user + +class UserView(UserMixin, MetadataMixin, TemplateView): + """ + display user information for another users + """ + template_name = 'client/accounts/user.html' + + def get_context_data(self, **kwargs): user = self.get_user() context = super(UserView, self).get_context_data(**kwargs) @@ -382,11 +385,11 @@ class UserEventView(ListView): obj = None event_type = None - def get_queryset(self): - url = self.kwargs.get('url') - user = get_user(url) - self.obj = user - return user.exposition_users.language().select_related('country').all() + # def get_queryset(self): + # url = self.kwargs.get('url') + # user = get_user(url) + # self.obj = user + # return user.exposition_users.language().select_related('country').all() def get_context_data(self, **kwargs): context = super(UserEventView, self).get_context_data(**kwargs) @@ -395,29 +398,27 @@ class UserEventView(ListView): return context -class UserExpositionsView(MetadataMixin, UserEventView): +class UserExpositionsView(UserMixin, MetadataMixin, UserEventView): """ return template with list of expos that user joined """ event_type = _(u'Выставки') def get_queryset(self): - url = self.kwargs.get('url') - user = get_user(url) + user = self.get_user() self.obj = user self.kwargs['user_full_name'] = user.get_full_name() return user.get_expos() -class UserConferenceView(MetadataMixin, UserEventView): +class UserConferenceView(UserMixin, MetadataMixin, UserEventView): """ return template with list of confs that user joined """ event_type = _(u'Конференции') def get_queryset(self): - url = self.kwargs.get('url') - user = get_user(url) + user = self.get_user() self.obj = user self.kwargs['user_full_name'] = user.get_full_name() return user.get_confs() diff --git a/conference/urls.py b/conference/urls.py index 157bb0de..d71ab5c9 100644 --- a/conference/urls.py +++ b/conference/urls.py @@ -23,81 +23,81 @@ from .views import ( urlpatterns = patterns('', - url(r'^conference/add-note/(?P.*)/$', 'conference.views.add_note'), + url(r'^conference/add-note/(?P[^/]*)/$', 'conference.views.add_note'), url(r'^conference-add-calendar/(?P\d+)/$', 'conference.views.conference_add_calendar'), url(r'^conference-visit/(?P\d+)/$', 'conference.views.conference_visit'), # search url(r'^conference/search/', ExpositionSearchView.as_view()), # country catalog url(r'^conference/country/$', ConferenceByCountry.as_view(), {'meta_id':51}), - url(r'^conference/country/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':25}), - url(r'^conference/country/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':24}), - url(r'^conference/country/(?P.*)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':23}), - url(r'^conference/country/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceCountryCatalog.as_view(), {'meta_id':25}), - url(r'^conference/country/(?P.*)/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':24}), - url(r'^conference/country/(?P.*)/$', ConferenceCountryCatalog.as_view(), {'meta_id':23}), + url(r'^conference/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':25}), + url(r'^conference/country/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':24}), + url(r'^conference/country/(?P[^/]*)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':23}), + url(r'^conference/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceCountryCatalog.as_view(), {'meta_id':25}), + url(r'^conference/country/(?P[^/]*)/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':24}), + url(r'^conference/country/(?P[^/]*)/$', ConferenceCountryCatalog.as_view(), {'meta_id':23}), # city catalog url(r'^conference/city/$', ConferenceByCity.as_view(), {'meta_id':52}), - url(r'^conference/city/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':28}), - url(r'^conference/city/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':27}), - url(r'^conference/city/(?P.*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':26}), - url(r'^conference/city/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceCityCatalog.as_view(), {'meta_id':28}), - url(r'^conference/city/(?P.*)/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':27}), - url(r'^conference/city/(?P.*)/$', ConferenceCityCatalog.as_view(), {'meta_id':26}), + url(r'^conference/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':28}), + url(r'^conference/city/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':27}), + url(r'^conference/city/(?P[^/]*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':26}), + url(r'^conference/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceCityCatalog.as_view(), {'meta_id':28}), + url(r'^conference/city/(?P[^/]*)/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':27}), + url(r'^conference/city/(?P[^/]*)/$', ConferenceCityCatalog.as_view(), {'meta_id':26}), # theme catalog url(r'^conference/theme/$', ConferenceByTheme.as_view(), {'meta_id':50}), - url(r'^conference/theme/(?P.*)/country/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/country/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/country/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/country/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/country/(?P.*)/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/country/(?P.*)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/country/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/country/(?P[^/]*)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/city/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/city/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/city/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/city/(?P.*)/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/city/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/city/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/city/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/city/(?P.*)/$', ConferenceThemeCatalog.as_view()), - url(r'^conference/theme/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':31}), - url(r'^conference/theme/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':30}), - url(r'^conference/theme/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':29}), - url(r'^conference/theme/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceThemeCatalog.as_view(), {'meta_id':31}), - url(r'^conference/theme/(?P.*)/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':30}), - url(r'^conference/theme/(?P.*)/$', ConferenceThemeCatalog.as_view(), {'meta_id':29}), + url(r'^conference/theme/(?P[^/]*)/city/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/city/(?P[^/]*)/$', ConferenceThemeCatalog.as_view()), + url(r'^conference/theme/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':31}), + url(r'^conference/theme/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':30}), + url(r'^conference/theme/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':29}), + url(r'^conference/theme/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceThemeCatalog.as_view(), {'meta_id':31}), + url(r'^conference/theme/(?P[^/]*)/(?P\d+)/$', ConferenceThemeCatalog.as_view(), {'meta_id':30}), + url(r'^conference/theme/(?P[^/]*)/$', ConferenceThemeCatalog.as_view(), {'meta_id':29}), # tag catalog url(r'^conference/tag/$', ConferenceByTag.as_view(), {'meta_id':50}), - url(r'^conference/tag/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':34}), - url(r'^conference/tag/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':33}), - url(r'^conference/tag/(?P.*)/page/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':32}), - url(r'^conference/tag/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceTagCatalog.as_view(), {'meta_id':34}), - url(r'^conference/tag/(?P.*)/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':33}), - url(r'^conference/tag/(?P.*)/$', ConferenceTagCatalog.as_view(), {'meta_id':32}), + url(r'^conference/tag/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':34}), + url(r'^conference/tag/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':33}), + url(r'^conference/tag/(?P[^/]*)/page/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':32}), + url(r'^conference/tag/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceTagCatalog.as_view(), {'meta_id':34}), + url(r'^conference/tag/(?P[^/]*)/(?P\d+)/$', ConferenceTagCatalog.as_view(), {'meta_id':33}), + url(r'^conference/tag/(?P[^/]*)/$', ConferenceTagCatalog.as_view(), {'meta_id':32}), # conf additional pages - url(r'^conference/(?P.*)/send_to_organiser/$', 'conference.views.send_to_organiser'), - url(r'^conference/(?P.*)/photo/page/(?P\d+)/$', ConferencePhotoView.as_view(), {'meta_id': 93}), - url(r'^conference/(?P.*)/photo/$', ConferencePhotoView.as_view(), {'meta_id': 93}), - url(r'^conference/(?P.*)/visitors/page/(?P\d+)/$', ConferenceVisitors.as_view()), - url(r'^conference/(?P.*)/visitors/$', ConferenceVisitors.as_view()), - url(r'^conference/(?P.*)/members/page/(?P\d+)/$', ConferenceMembers.as_view()), - url(r'^conference/(?P.*)/members/$', ConferenceMembers.as_view()), - url(r'^conference/(?P.*)/service/thanks/', ConferenceThankView.as_view()), - url(r'^conference/(?P.*)/service/visit/', 'conference.views.visit_redirect'), + url(r'^conference/(?P[^/]*)/send_to_organiser/$', 'conference.views.send_to_organiser'), + url(r'^conference/(?P[^/]*)/photo/page/(?P\d+)/$', ConferencePhotoView.as_view(), {'meta_id': 93}), + url(r'^conference/(?P[^/]*)/photo/$', ConferencePhotoView.as_view(), {'meta_id': 93}), + url(r'^conference/(?P[^/]*)/visitors/page/(?P\d+)/$', ConferenceVisitors.as_view()), + url(r'^conference/(?P[^/]*)/visitors/$', ConferenceVisitors.as_view()), + url(r'^conference/(?P[^/]*)/members/page/(?P\d+)/$', ConferenceMembers.as_view()), + url(r'^conference/(?P[^/]*)/members/$', ConferenceMembers.as_view()), + url(r'^conference/(?P[^/]*)/service/thanks/', ConferenceThankView.as_view()), + url(r'^conference/(?P[^/]*)/service/visit/', 'conference.views.visit_redirect'), - url(r'^conference/(?P.*)/service/(?P.*)/', ConferenceServiceView.as_view()), + url(r'^conference/(?P[^/]*)/service/(?P[^/]*)/', ConferenceServiceView.as_view()), # conf list - url(r'^conference/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceList.as_view(), {'meta_id':22}), + url(r'^conference/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceList.as_view(), {'meta_id':22}), url(r'^conference/(?P\d+)/page/(?P\d+)/$', ConferenceList.as_view(), {'meta_id':21}), - url(r'^conference/(?P\d+)/(?P.*)/$', ConferenceList.as_view(), {'meta_id':22}), + url(r'^conference/(?P\d+)/(?P[^/]*)/$', ConferenceList.as_view(), {'meta_id':22}), url(r'^conference/(?P\d+)/$', ConferenceList.as_view(), {'meta_id':21}), url(r'^conference/page/(?P\d+)/$', ConferenceList.as_view(), {'meta_id':20}), # conf page - url(r'^conference/(?P.*)/$', ConferenceDetail.as_view(), {'meta_id':35}), + url(r'^conference/(?P[^/]*)/$', ConferenceDetail.as_view(), {'meta_id':35}), url(r'^conference/$', ConferenceList.as_view(), {'meta_id':20}), ) diff --git a/exposition/urls.py b/exposition/urls.py index 8a0cd940..fdf29e00 100644 --- a/exposition/urls.py +++ b/exposition/urls.py @@ -32,65 +32,65 @@ urlpatterns = patterns('', # country catalog url(r'^expo/country/$', ExpositionByCountry.as_view(), {'meta_id':54}), - url(r'^expo/country/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':7}), - url(r'^expo/country/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':6}), - url(r'^expo/country/(?P.*)/page/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':5}), - url(r'^expo/country/(?P.*)/(?P\d+)/(?P.*)/$', ExpoCountryCatalog.as_view(), {'meta_id':7}), - url(r'^expo/country/(?P.*)/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':6}), - url(r'^expo/country/(?P.*)/$', ExpoCountryCatalog.as_view(), {'meta_id':5}), + url(r'^expo/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':7}), + url(r'^expo/country/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':6}), + url(r'^expo/country/(?P[^/]*)/page/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':5}), + url(r'^expo/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoCountryCatalog.as_view(), {'meta_id':7}), + url(r'^expo/country/(?P[^/]*)/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':6}), + url(r'^expo/country/(?P[^/]*)/$', ExpoCountryCatalog.as_view(), {'meta_id':5}), # city catalog url(r'^expo/city/$', ExpositionByCity.as_view(), {'meta_id':53}), - url(r'^expo/city/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':10}), - url(r'^expo/city/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':9}), - url(r'^expo/city/(?P.*)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':8}), - url(r'^expo/city/(?P.*)/(?P\d+)/(?P.*)/$', ExpoCityCatalog.as_view(), {'meta_id':10}), - url(r'^expo/city/(?P.*)/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':9}), - url(r'^expo/city/(?P.*)/$', ExpoCityCatalog.as_view(), {'meta_id':8}), + url(r'^expo/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':10}), + url(r'^expo/city/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':9}), + url(r'^expo/city/(?P[^/]*)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':8}), + url(r'^expo/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoCityCatalog.as_view(), {'meta_id':10}), + url(r'^expo/city/(?P[^/]*)/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':9}), + url(r'^expo/city/(?P[^/]*)/$', ExpoCityCatalog.as_view(), {'meta_id':8}), # theme catalog url(r'^expo/theme/$', ExpositionByTheme.as_view(), {'meta_id':55}), - url(r'^expo/theme/(?P.*)/country/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), - url(r'^expo/theme/(?P.*)/country/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), - url(r'^expo/theme/(?P.*)/country/(?P.*)/(?P\d+)/(?P.*)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), - url(r'^expo/theme/(?P.*)/country/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), - url(r'^expo/theme/(?P.*)/country/(?P.*)/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), - url(r'^expo/theme/(?P.*)/country/(?P.*)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), + url(r'^expo/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), + url(r'^expo/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), + url(r'^expo/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), + url(r'^expo/theme/(?P[^/]*)/country/(?P[^/]*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), + url(r'^expo/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), + url(r'^expo/theme/(?P[^/]*)/country/(?P[^/]*)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), - url(r'^expo/theme/(?P.*)/city/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), - url(r'^expo/theme/(?P.*)/city/(?P.*)/(?P\d+)/(?P.*)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), - url(r'^expo/theme/(?P.*)/city/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), - url(r'^expo/theme/(?P.*)/city/(?P.*)/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), + url(r'^expo/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), + url(r'^expo/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), + url(r'^expo/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), + url(r'^expo/theme/(?P[^/]*)/city/(?P[^/]*)/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), + url(r'^expo/theme/(?P[^/]*)/city/(?P[^/]*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), + url(r'^expo/theme/(?P[^/]*)/city/(?P[^/]*)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), - url(r'^expo/theme/(?P.*)/city/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), - url(r'^expo/theme/(?P.*)/city/(?P.*)/$', ExpoThemeCatalog.as_view(), {'meta_id':42}), - url(r'^expo/theme/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':13}), - url(r'^expo/theme/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':12}), - url(r'^expo/theme/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':11}), - url(r'^expo/theme/(?P.*)/(?P\d+)/(?P.*)/$', ExpoThemeCatalog.as_view(), {'meta_id':13}), - url(r'^expo/theme/(?P.*)/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':12}), - url(r'^expo/theme/(?P.*)/$', ExpoThemeCatalog.as_view(), {'meta_id':11}), + url(r'^expo/theme/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':13}), + url(r'^expo/theme/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':12}), + url(r'^expo/theme/(?P[^/]*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':11}), + url(r'^expo/theme/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoThemeCatalog.as_view(), {'meta_id':13}), + url(r'^expo/theme/(?P[^/]*)/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':12}), + url(r'^expo/theme/(?P[^/]*)/$', ExpoThemeCatalog.as_view(), {'meta_id':11}), # tag catalog - url(r'^expo/tag/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':17}), - url(r'^expo/tag/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':15}), - url(r'^expo/tag/(?P.*)/page/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':14}), - url(r'^expo/tag/(?P.*)/(?P\d+)/(?P.*)/$', ExpoTagCatalog.as_view(), {'meta_id':17}), - url(r'^expo/tag/(?P.*)/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':15}), - url(r'^expo/tag/(?P.*)/$', ExpoTagCatalog.as_view(), {'meta_id':14}), + url(r'^expo/tag/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':17}), + url(r'^expo/tag/(?P[^/]*)/(?P\d+)/page/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':15}), + url(r'^expo/tag/(?P[^/]*)/page/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':14}), + url(r'^expo/tag/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoTagCatalog.as_view(), {'meta_id':17}), + url(r'^expo/tag/(?P[^/]*)/(?P\d+)/$', ExpoTagCatalog.as_view(), {'meta_id':15}), + url(r'^expo/tag/(?P[^/]*)/$', ExpoTagCatalog.as_view(), {'meta_id':14}), # expo additional pages - url(r'^expo/(?P.*)/send_to_organiser/$', 'exposition.views.send_to_organiser'), - url(r'^expo/(?P.*)/statistic/$', ExpositionStatistic.as_view(), {'meta_id':60}), - url(r'^expo/(?P.*)/price/$', ExpositionPrice.as_view(), {'meta_id':61}), - url(r'^expo/(?P.*)/program/$', ExpositionProgramme.as_view(), {'meta_id':62}), - url(r'^expo/(?P.*)/visitors/page/(?P\d+)/$', ExpoVisitors.as_view(), {'meta_id':64}), - url(r'^expo/(?P.*)/visitors/$', ExpoVisitors.as_view(), {'meta_id':64}), - url(r'^expo/(?P.*)/photo/page/(?P\d+)/$', ExpoPhotoView.as_view(), {'meta_id': 92}), - url(r'^expo/(?P.*)/photo/$', ExpoPhotoView.as_view(), {'meta_id': 92}), - url(r'^expo/(?P.*)/members/page/(?P\d+)/$', ExpoMembers.as_view(), {'meta_id':63}), - url(r'^expo/(?P.*)/members/$', ExpoMembers.as_view(), {'meta_id':63}), - url(r'^expo/(?P.*)/service/thanks/', ExpositionThankView.as_view()), - url(r'^expo/(?P.*)/service/visit/', 'exposition.views.visit_redirect'), - url(r'^expo/(?P.*)/service/(?P.*)/', ExpositionServiceView.as_view()), + url(r'^expo/(?P[^/]*)/send_to_organiser/$', 'exposition.views.send_to_organiser'), + url(r'^expo/(?P[^/]*)/statistic/$', ExpositionStatistic.as_view(), {'meta_id':60}), + url(r'^expo/(?P[^/]*)/price/$', ExpositionPrice.as_view(), {'meta_id':61}), + url(r'^expo/(?P[^/]*)/program/$', ExpositionProgramme.as_view(), {'meta_id':62}), + url(r'^expo/(?P[^/]*)/visitors/page/(?P\d+)/$', ExpoVisitors.as_view(), {'meta_id':64}), + url(r'^expo/(?P[^/]*)/visitors/$', ExpoVisitors.as_view(), {'meta_id':64}), + url(r'^expo/(?P[^/]*)/photo/page/(?P\d+)/$', ExpoPhotoView.as_view(), {'meta_id': 92}), + url(r'^expo/(?P[^/]*)/photo/$', ExpoPhotoView.as_view(), {'meta_id': 92}), + url(r'^expo/(?P[^/]*)/members/page/(?P\d+)/$', ExpoMembers.as_view(), {'meta_id':63}), + url(r'^expo/(?P[^/]*)/members/$', ExpoMembers.as_view(), {'meta_id':63}), + url(r'^expo/(?P[^/]*)/service/thanks/', ExpositionThankView.as_view()), + url(r'^expo/(?P[^/]*)/service/visit/', 'exposition.views.visit_redirect'), + url(r'^expo/(?P[^/]*)/service/(?P[^/]*)/', ExpositionServiceView.as_view()), # expo list - url(r'^expo/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoList.as_view(), {'meta_id':4}), + url(r'^expo/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoList.as_view(), {'meta_id':4}), url(r'^expo/(?P\d+)/page/(?P\d+)/$', ExpoList.as_view(), {'meta_id':3}), url(r'^expo/(?P\d+)/(?P.*)/$', ExpoList.as_view(), {'meta_id':4}), url(r'^expo/(?P\d+)/$', ExpoList.as_view(), {'meta_id':3}), diff --git a/meta/models.py b/meta/models.py index c0002aa1..9643ad96 100644 --- a/meta/models.py +++ b/meta/models.py @@ -150,14 +150,12 @@ class SeoTextManager(TranslationManager): url = kwargs.get('url') lang = kwargs.get('lang')[:2] or translation.get_language()[:2] key = 'seo_text_cache' - if key in cache: - result = cache.get(key) - return result.get("%s_%s" % (lang, url)) - else: + result = cache.get(key) + if result is None: qs = list(SeoText.objects.language('all')) - value_dict = {obj.language_code+'_'+obj.url: obj for obj in qs} - cache.set(key, value_dict, self.cache_time) - return value_dict.get("%s_%s" % (lang, url)) + result = {obj.language_code+'_'+obj.url: obj for obj in qs} + cache.set(key, result, self.cache_time) + return result.get("%s_%s" % (lang, url), None) class SeoText(TranslatableModel): diff --git a/templates/client/article/news.html b/templates/client/article/news.html index 5a26e8f3..c638478a 100644 --- a/templates/client/article/news.html +++ b/templates/client/article/news.html @@ -55,7 +55,7 @@
- +
{% for news in object.similar %}
diff --git a/templates/client/includes/place/place_object.html b/templates/client/includes/place/place_object.html index cdd69757..0ace3dce 100644 --- a/templates/client/includes/place/place_object.html +++ b/templates/client/includes/place/place_object.html @@ -206,8 +206,8 @@
{{ pl.total_area }}
{% endif %}
@@ -238,4 +238,4 @@ } }); -{% endblock %} \ No newline at end of file +{% endblock %} From a89358e3d642bd444e8ef83471bb2b3b8b9ae5b1 Mon Sep 17 00:00:00 2001 From: Alexander Burdeiny Date: Wed, 3 Aug 2016 11:34:19 +0300 Subject: [PATCH 2/2] =?UTF-8?q?1498:=20=D0=92=D0=BD=D0=B5=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BE=20=D1=81=D0=BE=20=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=D0=B9=D0=BF=D0=B0=20-=20=D1=80=D0=B5=D0=B4=D0=B8=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D1=8B=20301?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conference/urls.py | 4 +-- exposition/urls.py | 4 +-- place_exposition/urls.py | 4 +-- proj/middleware.py | 65 ++++++++++++++++++++++++++++++++++++++++ settings/old_urls.py | 1 + support/dev/settings.py | 1 + support/prod/settings.py | 2 +- 7 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 proj/middleware.py diff --git a/conference/urls.py b/conference/urls.py index d71ab5c9..f7e4729e 100644 --- a/conference/urls.py +++ b/conference/urls.py @@ -35,7 +35,7 @@ urlpatterns = patterns('', url(r'^conference/country/(?P[^/]*)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':23}), url(r'^conference/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceCountryCatalog.as_view(), {'meta_id':25}), url(r'^conference/country/(?P[^/]*)/(?P\d+)/$', ConferenceCountryCatalog.as_view(), {'meta_id':24}), - url(r'^conference/country/(?P[^/]*)/$', ConferenceCountryCatalog.as_view(), {'meta_id':23}), + url(r'^conference/country/(?P[^/]*)/$', ConferenceCountryCatalog.as_view(), {'meta_id':23}, name='conf_country'), # city catalog url(r'^conference/city/$', ConferenceByCity.as_view(), {'meta_id':52}), url(r'^conference/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':28}), @@ -43,7 +43,7 @@ urlpatterns = patterns('', url(r'^conference/city/(?P[^/]*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':26}), url(r'^conference/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ConferenceCityCatalog.as_view(), {'meta_id':28}), url(r'^conference/city/(?P[^/]*)/(?P\d+)/$', ConferenceCityCatalog.as_view(), {'meta_id':27}), - url(r'^conference/city/(?P[^/]*)/$', ConferenceCityCatalog.as_view(), {'meta_id':26}), + url(r'^conference/city/(?P[^/]*)/$', ConferenceCityCatalog.as_view(), {'meta_id':26}, name='conf_city'), # theme catalog url(r'^conference/theme/$', ConferenceByTheme.as_view(), {'meta_id':50}), url(r'^conference/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), diff --git a/exposition/urls.py b/exposition/urls.py index fdf29e00..f5df260e 100644 --- a/exposition/urls.py +++ b/exposition/urls.py @@ -37,7 +37,7 @@ urlpatterns = patterns('', url(r'^expo/country/(?P[^/]*)/page/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':5}), url(r'^expo/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoCountryCatalog.as_view(), {'meta_id':7}), url(r'^expo/country/(?P[^/]*)/(?P\d+)/$', ExpoCountryCatalog.as_view(), {'meta_id':6}), - url(r'^expo/country/(?P[^/]*)/$', ExpoCountryCatalog.as_view(), {'meta_id':5}), + url(r'^expo/country/(?P[^/]*)/$', ExpoCountryCatalog.as_view(), {'meta_id':5}, name='expo_country'), # city catalog url(r'^expo/city/$', ExpositionByCity.as_view(), {'meta_id':53}), url(r'^expo/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':10}), @@ -45,7 +45,7 @@ urlpatterns = patterns('', url(r'^expo/city/(?P[^/]*)/page/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':8}), url(r'^expo/city/(?P[^/]*)/(?P\d+)/(?P[^/]*)/$', ExpoCityCatalog.as_view(), {'meta_id':10}), url(r'^expo/city/(?P[^/]*)/(?P\d+)/$', ExpoCityCatalog.as_view(), {'meta_id':9}), - url(r'^expo/city/(?P[^/]*)/$', ExpoCityCatalog.as_view(), {'meta_id':8}), + url(r'^expo/city/(?P[^/]*)/$', ExpoCityCatalog.as_view(), {'meta_id':8}, name='expo_city'), # theme catalog url(r'^expo/theme/$', ExpositionByTheme.as_view(), {'meta_id':55}), url(r'^expo/theme/(?P[^/]*)/country/(?P[^/]*)/(?P\d+)/(?P[^/]*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view(), {'meta_id':44}), diff --git a/place_exposition/urls.py b/place_exposition/urls.py index 908e4ee6..c9b64235 100644 --- a/place_exposition/urls.py +++ b/place_exposition/urls.py @@ -15,11 +15,11 @@ 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}), + 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}), + 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/$', PlacePhoto.as_view(), {'meta_id': 91}), diff --git a/proj/middleware.py b/proj/middleware.py new file mode 100644 index 00000000..33ce635f --- /dev/null +++ b/proj/middleware.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# from django.contrib.redirects.middleware import RedirectFallbackMiddleware +import re + +from django.http import HttpResponsePermanentRedirect +from django.core.urlresolvers import reverse + +from exposition.models import Exposition +from country.models import Country +from city.models import City + + +class RedirectFallbackMiddleware(object): + def process_response(self, request, response): + if response.status_code != 404: + return response # No need to check for a redirect for non-404 responses. + + full_path = request.get_full_path() + + redirects = [ + (r'^/(?Pexpo|conference)/(?P[^/]*)/$', check_events), + (r'^/places/(?P[^/]*)/$', check_places), + ] + + for regex, handler in redirects: + check = re.compile(regex) + match = check.match(full_path) + if match: + response = handler(**match.groupdict()) + if response is not None: + return response + return response + + +def check_events(event_type, slug): + ''' + Event redirects (ticket 1498: Внепланово со скайпа - редиректы 301) + https://expomap.ru/expo/dusseldorf/ -> https://expomap.ru/expo/city/dusseldorf/ + https://expomap.ru/expo/moscow/ -> https://expomap.ru/expo/country/moscow/ + https://expomap.ru/conference/berlin/ -> https://expomap.ru/conference/city/berlin/ + https://expomap.ru/conference/moscow/ -> https://expomap.ru/conference/country/moscow/ + ''' + types = { + 'expo': 'expo', + 'conference': 'conf' + } + if City.objects.filter(url=slug).exists(): + return HttpResponsePermanentRedirect(reverse(types.get(event_type) + '_city', kwargs={'slug': slug})) + if Country.objects.filter(url=slug).exists(): + return HttpResponsePermanentRedirect(reverse(types.get(event_type) + '_country', kwargs={'slug': slug})) + return None + + +def check_places(slug): + """ + Правила для старых ошибок (ticket 1498: Внепланово со скайпа - редиректы 301) + https://expomap.ru/places/russia/ -> https://expomap.ru/places/country/russia/ + https://expomap.ru/places/moscow/ -> https://expomap.ru/places/city/moscow/ + - где пропущен параметр city и country - тоже автоматической склейки по 301 + """ + if City.objects.filter(url=slug).exists(): + return HttpResponsePermanentRedirect(reverse('place_city', kwargs={'slug': slug})) + if Country.objects.filter(url=slug).exists(): + return HttpResponsePermanentRedirect(reverse('place_country', kwargs={'slug': slug})) + return None diff --git a/settings/old_urls.py b/settings/old_urls.py index f64a48d1..987a3e20 100644 --- a/settings/old_urls.py +++ b/settings/old_urls.py @@ -39,6 +39,7 @@ urlpatterns = patterns('', url(r'^newsp.php/news_id/(?P\d+)/(?P.*)$', old_redirect, {'redirect_url': '/news/{news_p}/'}), # users url(r'^users/(?P.*)$', old_redirect, {'redirect_url': '/{user}/'}), + url(r'^user/(?P.*)$', old_redirect, {'redirect_url': '/{user}/'}), url(r'^account_edit.php$', old_profile), url(r'^myexpo.php$', old_redirect, {'redirect_url': '/profile/calendar/'}), url(r'^newsletter2.php?email=(?P.*)$', old_redirect, {'redirect_url': '/profile/settings/'}), diff --git a/support/dev/settings.py b/support/dev/settings.py index def623f3..e6585d3b 100644 --- a/support/dev/settings.py +++ b/support/dev/settings.py @@ -153,6 +153,7 @@ MIDDLEWARE_CLASSES = ( # Uncomment the next line for simple clickjacking protection: 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', + 'proj.middleware.RedirectFallbackMiddleware', ) diff --git a/support/prod/settings.py b/support/prod/settings.py index 679749e6..b3664880 100644 --- a/support/prod/settings.py +++ b/support/prod/settings.py @@ -153,7 +153,7 @@ MIDDLEWARE_CLASSES = ( # Uncomment the next line for simple clickjacking protection: 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', - + 'proj.middleware.RedirectFallbackMiddleware', )