From 08a214a6dceb5f7efa712625f4f30126861edc96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=9A=D0=BE=D1=82=D1=8E?= =?UTF-8?q?=D0=BA?= Date: Wed, 1 Apr 2015 23:21:08 +0300 Subject: [PATCH] Meta --- .gitignore | 2 +- article/urls.py | 4 +- article/views.py | 5 +- conference/forms.py | 3 +- conference/urls.py | 62 +++++++++--------- conference/views.py | 15 +++-- exposition/models.py | 2 +- exposition/urls.py | 60 +++++++++--------- exposition/views.py | 27 +++++--- import_xls/admin.py | 6 +- import_xls/admin_urls.py | 3 +- import_xls/export_forms.py | 12 ++++ meta/models.py | 63 ++++++++++++++----- meta/views.py | 8 ++- proj/production.py | 4 +- proj/settings.py | 12 ++-- service/models.py | 1 + templates/client/conference/catalog.html | 2 +- .../client/conference/catalog_theme.html | 2 +- .../client/conference/conference_list.html | 2 +- templates/client/exposition/catalog.html | 3 +- .../client/exposition/catalog_theme.html | 3 +- templates/client/service/catalog.html | 2 +- templates/client/service/participation.html | 2 +- templates/client/service/remotely.html | 2 +- templates/client/service/tickets.html | 2 +- templates/client/service/tour.html | 2 +- templates/client/service/translator.html | 2 +- 28 files changed, 194 insertions(+), 119 deletions(-) diff --git a/.gitignore b/.gitignore index 3a849c70..3fc5210e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,5 @@ Thumbs.db npm-debug.log /proj/local.py -atlassian-ide-plugin.xml + diff --git a/article/urls.py b/article/urls.py index 4fcd7d52..ea86eb8f 100644 --- a/article/urls.py +++ b/article/urls.py @@ -7,6 +7,6 @@ urlpatterns = patterns('', url(r'blogs/$', BlogList.as_view()), url(r'news/page/(?P\d+)/$', NewsList.as_view()), url(r'news/$', NewsList.as_view()), - url(r'blogs/(?P.*)/$', BlogDetail.as_view()), - url(r'news/(?P.*)/$', NewsDetail.as_view()), + url(r'blogs/(?P.*)/$', BlogDetail.as_view(), {'meta_id':19}), + url(r'news/(?P.*)/$', NewsDetail.as_view(), {'meta_id':19}), ) diff --git a/article/views.py b/article/views.py index dd80ef8b..c4d6ea94 100644 --- a/article/views.py +++ b/article/views.py @@ -4,6 +4,7 @@ from django.http import HttpResponse from models import Article from forms import ArticleFilterForm from theme.models import Tag +from meta.views import MetadataMixin @@ -51,7 +52,7 @@ class NewsList(ListView): -class NewsDetail(DetailView): +class NewsDetail(MetadataMixin, DetailView): model = Article slug_field = 'slug' template_name = 'article/news.html' @@ -102,7 +103,7 @@ class BlogList(ListView): -class BlogDetail(DetailView): +class BlogDetail(MetadataMixin, DetailView): model = Article slug_field = 'slug' template_name = 'article/article.html' \ No newline at end of file diff --git a/conference/forms.py b/conference/forms.py index ab952ef3..cf3fa4cd 100644 --- a/conference/forms.py +++ b/conference/forms.py @@ -193,7 +193,7 @@ class ConferenceCreateForm(forms.Form): conference.save() return conference - + """ def clean(self): id = self.cleaned_data.get('conference_id') name_ru = self.cleaned_data.get('name_ru') @@ -205,6 +205,7 @@ class ConferenceCreateForm(forms.Form): del self.cleaned_data['name_ru'] return self.cleaned_data + """ def clean_tag(self): tags = self.cleaned_data.get('tag') diff --git a/conference/urls.py b/conference/urls.py index 6e8b60f7..b48894fd 100644 --- a/conference/urls.py +++ b/conference/urls.py @@ -15,39 +15,39 @@ urlpatterns = patterns('', url(r'conference/search/', ExpositionSearchView.as_view()), # country catalog url(r'conference/country/$', ConferenceByCountry.as_view()), - url(r'conference/country/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view()), - url(r'conference/country/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view()), - url(r'conference/country/(?P.*)/page/(?P\d+)/$', ConferenceCountryCatalog.as_view()), - url(r'conference/country/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceCountryCatalog.as_view()), - url(r'conference/country/(?P.*)/(?P\d+)/$', ConferenceCountryCatalog.as_view()), - url(r'conference/country/(?P.*)/$', ConferenceCountryCatalog.as_view()), + 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()), - url(r'conference/city/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view()), - url(r'conference/city/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceCityCatalog.as_view()), - url(r'conference/city/(?P.*)/page/(?P\d+)/$', ConferenceCityCatalog.as_view()), - url(r'conference/city/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceCityCatalog.as_view()), - url(r'conference/city/(?P.*)/(?P\d+)/$', ConferenceCityCatalog.as_view()), - url(r'conference/city/(?P.*)/$', ConferenceCityCatalog.as_view()), + 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()), url(r'conference/theme/(?P.*)/country/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), url(r'conference/theme/(?P.*)/country/(?P.*)/$', 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()), - url(r'conference/theme/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'conference/theme/(?P.*)/page/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'conference/theme/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceThemeCatalog.as_view()), - url(r'conference/theme/(?P.*)/(?P\d+)/$', ConferenceThemeCatalog.as_view()), - url(r'conference/theme/(?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/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceTagCatalog.as_view()), - url(r'conference/tag/(?P.*)/(?P\d+)/page/(?P\d+)/$', ConferenceTagCatalog.as_view()), - url(r'conference/tag/(?P.*)/page/(?P\d+)/$', ConferenceTagCatalog.as_view()), - url(r'conference/tag/(?P.*)/(?P\d+)/(?P.*)/$', ConferenceTagCatalog.as_view()), - url(r'conference/tag/(?P.*)/(?P\d+)/$', ConferenceTagCatalog.as_view()), - url(r'conference/tag/(?P.*)/$', ConferenceTagCatalog.as_view()), + 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.*)/visitors/page/(?P\d+)/$', ConferenceVisitors.as_view()), url(r'conference/(?P.*)/visitors/$', ConferenceVisitors.as_view()), @@ -56,14 +56,14 @@ urlpatterns = patterns('', url(r'conference/(?P.*)/service/(?P.*)/', ConferenceServiceView.as_view()), # conf list - url(r'conference/(?P\d+)/(?P.*)/page/(?P\d+)/$', ConferenceList.as_view()), - url(r'conference/(?P\d+)/page/(?P\d+)/$', ConferenceList.as_view()), - url(r'conference/(?P\d+)/(?P.*)/$', ConferenceList.as_view()), - url(r'conference/(?P\d+)/$', ConferenceList.as_view()), - url(r'conference/page/(?P\d+)/$', ConferenceList.as_view()), + 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+)/$', 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()), - url(r'conference/$', ConferenceList.as_view()), + url(r'conference/(?P.*)/$', ConferenceDetail.as_view(), {'meta_id':35}), + url(r'conference/$', ConferenceList.as_view(), {'meta_id':20}), ) diff --git a/conference/views.py b/conference/views.py index fe095af0..1d851fd7 100644 --- a/conference/views.py +++ b/conference/views.py @@ -18,6 +18,7 @@ from city.models import City from theme.models import Theme, Tag from service.order_forms import AdvertiseForm from functions.search_forms import ExpositionSearchForm +from meta.views import MetadataMixin MONTHES = settings.MONTHES @@ -75,7 +76,7 @@ class ConferenceByCity(ConferenceBy): .order_by('translations__name').distinct() -class ConferenceCatalog(ListView): +class ConferenceCatalog(MetadataMixin, ListView): model = Conference paginate_by = settings.CLIENT_PAGINATION template_name = 'client/conference/catalog.html' @@ -145,6 +146,7 @@ class ConferenceCountryCatalog(ConferenceCatalog): #this method used in parent get_queryset slug = self.kwargs.get('slug') country = get_object_or_404(Country, url=slug) + self.kwargs['country'] = country self.filter_object = country qs = self.model.enable.filter(country=country) return qs @@ -155,6 +157,7 @@ class ConferenceCityCatalog(ConferenceCatalog): #this method used in parent get_queryset slug = self.kwargs.get('slug') city = get_object_or_404(City, url=slug) + self.kwargs['city'] = city qs = self.model.enable.filter(city=city) self.filter_object = city return qs @@ -172,6 +175,7 @@ class ConferenceThemeCatalog(ConferenceCatalog): country_slug = self.kwargs.get('country_slug') city_slug = self.kwargs.get('city_slug') theme = get_object_or_404(Theme, url=slug) + self.kwargs['theme'] = theme qs = self.model.enable.filter(theme=theme) if country_slug: @@ -202,12 +206,13 @@ class ConferenceTagCatalog(ConferenceCatalog): #this method used in parent get_queryset slug = self.kwargs.get('slug') tag = get_object_or_404(Tag, url=slug) + self.kwargs['tag'] = tag qs = self.model.enable.filter(tag=tag) self.filter_object = tag return qs -class ConferenceVisitors(ListView): +class ConferenceVisitors(MetadataMixin, ListView): paginate_by = settings.CLIENT_PAGINATION model = Conference #template_name = 'event_visitors.html' @@ -230,7 +235,7 @@ class ConferenceVisitors(ListView): return context -class ConferenceMembers(ListView): +class ConferenceMembers(MetadataMixin, ListView): paginate_by = settings.CLIENT_PAGINATION model = Conference #template_name = 'event_visitors.html' @@ -315,7 +320,7 @@ class ConferenceServiceView(FormMixin, DetailView): -class ConferenceDetail(DetailView): +class ConferenceDetail(MetadataMixin, DetailView): model = Conference slug_field = 'url' template_name = 'client/conference/conference_detail.html' @@ -325,7 +330,7 @@ class ConferenceDetail(DetailView): context['advertising_form'] = AdvertiseForm() return context -class ConferenceList(ListView): +class ConferenceList(MetadataMixin, ListView): model = Conference paginate_by = settings.CLIENT_PAGINATION template_name = 'client/conference/conference_list.html' diff --git a/exposition/models.py b/exposition/models.py index 36a57f1f..777a9b48 100644 --- a/exposition/models.py +++ b/exposition/models.py @@ -247,7 +247,7 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): if self.theme.all(): theme = self.theme.all()[0] now = datetime.datetime.now() - now = now.replace(day=now.day-1) + now = now - datetime.timedelta(days=1) expositions = Exposition.objects.filter(theme__in=[theme], data_begin__gt=now).exclude(id=self.id).order_by('data_begin') return expositions[:3] else: diff --git a/exposition/urls.py b/exposition/urls.py index bef39cb4..03f6711a 100644 --- a/exposition/urls.py +++ b/exposition/urls.py @@ -17,45 +17,43 @@ urlpatterns = patterns('', # search url(r'expo/search/', ExpositionSearchView.as_view()), - - # country catalog url(r'expo/country/$', ExpositionByCountry.as_view()), - url(r'expo/country/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoCountryCatalog.as_view()), - url(r'expo/country/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoCountryCatalog.as_view()), - url(r'expo/country/(?P.*)/page/(?P\d+)/$', ExpoCountryCatalog.as_view()), - url(r'expo/country/(?P.*)/(?P\d+)/(?P.*)/$', ExpoCountryCatalog.as_view()), - url(r'expo/country/(?P.*)/(?P\d+)/$', ExpoCountryCatalog.as_view()), + 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()), - url(r'expo/city/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoCityCatalog.as_view()), - url(r'expo/city/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoCityCatalog.as_view()), - url(r'expo/city/(?P.*)/page/(?P\d+)/$', ExpoCityCatalog.as_view()), - url(r'expo/city/(?P.*)/(?P\d+)/(?P.*)/$', ExpoCityCatalog.as_view()), - url(r'expo/city/(?P.*)/(?P\d+)/$', ExpoCityCatalog.as_view()), - url(r'expo/city/(?P.*)/$', ExpoCityCatalog.as_view()), + 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()), - url(r'expo/theme/(?P.*)/country/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/country/(?P.*)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/city/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/city/(?P.*)/$', ExpoThemeCatalog.as_view()), - - url(r'expo/theme/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/page/(?P\d+)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/(?P\d+)/(?P.*)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/(?P\d+)/$', ExpoThemeCatalog.as_view()), - url(r'expo/theme/(?P.*)/$', ExpoThemeCatalog.as_view()), + url(r'expo/theme/(?P.*)/country/(?P.*)/page/(?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.*)/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}), # tag catalog - url(r'expo/tag/(?P.*)/(?P\d+)/(?P.*)/page/(?P\d+)/$', ExpoTagCatalog.as_view()), - url(r'expo/tag/(?P.*)/(?P\d+)/page/(?P\d+)/$', ExpoTagCatalog.as_view()), - url(r'expo/tag/(?P.*)/page/(?P\d+)/$', ExpoTagCatalog.as_view()), - url(r'expo/tag/(?P.*)/(?P\d+)/(?P.*)/$', ExpoTagCatalog.as_view()), - url(r'expo/tag/(?P.*)/(?P\d+)/$', ExpoTagCatalog.as_view()), - url(r'expo/tag/(?P.*)/$', ExpoTagCatalog.as_view()), + 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.*)/statistic/$', ExpositionStatistic.as_view()), url(r'expo/(?P.*)/price/$', ExpositionPrice.as_view()), @@ -73,7 +71,7 @@ urlpatterns = patterns('', url(r'expo/(?P\d+)/$', ExpoList.as_view(), {'meta_id':3}), url(r'expo/page/(?P\d+)/$', ExpoList.as_view(), {'meta_id':2}), # expo page - url(r'expo/(?P.*)/$', ExpoDetail.as_view()),# event + url(r'expo/(?P.*)/$', ExpoDetail.as_view(), {'meta_id':18}),# event url(r'expo/$', ExpoList.as_view(), {'meta_id':2}), diff --git a/exposition/views.py b/exposition/views.py index 7eed4ccd..ac75bfe9 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -128,7 +128,7 @@ def exposition_visit(request, id): #------------------------------------------------------------------------------ -class ExpoDetail(DetailView): +class ExpoDetail(MetadataMixin, DetailView): model = Exposition slug_field = 'url' template_name = 'client/exposition/exposition_detail.html' @@ -157,11 +157,18 @@ class ExpositionStatistic(DetailView): template_name = 'client/exposition/statistic.html' from django.views.generic.edit import FormMixin, ModelFormMixin -class ExpositionServiceView(FormMixin, DetailView): +class ExpositionServiceView(MetadataMixin, FormMixin, DetailView): model = Exposition slug_field = 'url' service = None + def dispatch(self, request, *args, **kwargs): + service_url = self.kwargs.get('service_url') + service = get_object_or_404(Service, url=service_url) + self.service = service + self.template_name = service.template + return super(ExpositionServiceView, self).dispatch(request, *args, **kwargs) + def post(self, request, *args, **kwargs): self.object = self.get_object() service_url = self.kwargs.get('service_url') @@ -176,17 +183,16 @@ class ExpositionServiceView(FormMixin, DetailView): return self.form_invalid(form) def get_context_data(self, **kwargs): + kwargs.update({'meta_id': getattr(self.service, 'meta_id','')}) + context = super(ExpositionServiceView, self).get_context_data(**kwargs) service_url = self.kwargs.get('service_url') - service = get_object_or_404(Service, url=service_url) - self.service = service - self.template_name = service.template form = order_forms.get(service_url) self.form_class = form if not form: raise Http404 context['form'] = self.get_form(self.form_class) - context['service'] = service + context['service'] = self.service context['object'] = self.get_object() return context @@ -257,7 +263,7 @@ class ExpoList(MetadataMixin, ListView): MONTHES = settings.MONTHES -class ExpoCatalog(ListView): +class ExpoCatalog(MetadataMixin, ListView): model = Exposition paginate_by = settings.CLIENT_PAGINATION template_name = 'exposition/catalog.html' @@ -321,7 +327,7 @@ class ExpoCatalog(ListView): context['catalog_url'] = self.catalog_url return context -class ExpoCountryCatalog(MetadataMixin, ExpoCatalog): +class ExpoCountryCatalog(ExpoCatalog): catalog_url = '/expo/country/' def get_filtered_qs(self): #this method used in parent get_queryset @@ -338,6 +344,7 @@ class ExpoCityCatalog(ExpoCatalog): #this method used in parent get_queryset slug = self.kwargs.get('slug') city = get_object_or_404(City, url=slug) + self.kwargs['city'] = city qs = self.model.enable.filter(city=city) self.filter_object = city return qs @@ -355,16 +362,19 @@ class ExpoThemeCatalog(ExpoCatalog): country_slug = self.kwargs.get('country_slug') city_slug = self.kwargs.get('city_slug') theme = get_object_or_404(Theme, url=slug) + self.kwargs['theme'] = theme qs = self.model.enable.filter(theme=theme) if country_slug: country = get_object_or_404(Country, url=country_slug) self.country = country + self.kwargs['country'] = country qs = qs.filter(country=country) if city_slug: city = get_object_or_404(City, url=city_slug) self.city = city + self.kwargs['city'] = city qs = qs.filter(city=city) self.filter_object = theme @@ -385,6 +395,7 @@ class ExpoTagCatalog(ExpoCatalog): #this method used in parent get_queryset slug = self.kwargs.get('slug') tag = get_object_or_404(Tag, url=slug) + self.kwargs['tag'] = tag qs = self.model.enable.filter(tag=tag) self.filter_object = tag return qs diff --git a/import_xls/admin.py b/import_xls/admin.py index 00ebe370..aad23f02 100644 --- a/import_xls/admin.py +++ b/import_xls/admin.py @@ -11,7 +11,7 @@ import xlrd from import_forms import ImportEventForm, ImportThemeForm, ImportTagForm, ImportOrganiserForm,\ ImportPlaceConferenceForm, ImportPlaceExpositionForm from export_forms import ExportEventForm, ExportOrganiserForm, ExportThemeForm, ExportTagForm,\ - ExportUserForm, ExportCompanyForm, ExportPlaceConferenceForm, ExportPlaceExpositionForm + ExportUserForm, ExportCompanyForm, ExportPlaceConferenceForm, ExportPlaceExpositionForm, ExportBlogForm from django.views.generic import FormView from django.contrib import messages @@ -78,6 +78,10 @@ class ExportPlaceExposition(ExportView): form_class = ExportPlaceExpositionForm success_url = '/admin/export-place_exposition' +class ExportBlog(ExportView): + form_class = ExportBlogForm + success_url = '/admin/export-blog/' + from exposition.models import Exposition diff --git a/import_xls/admin_urls.py b/import_xls/admin_urls.py index d96f53de..527435fb 100644 --- a/import_xls/admin_urls.py +++ b/import_xls/admin_urls.py @@ -3,7 +3,7 @@ from django.conf.urls import patterns, url from admin import ImportTheme, ImportEvent, ImportOrganiser, ImportTag, ImportPlaceExposition, ImportPlaceConference from admin import ExportTheme, ExportEvent, ExportOrganiser, ExportTag, ExportPlaceExposition,\ - ExportPlaceConference, ExportCompany, ExportUser + ExportPlaceConference, ExportCompany, ExportUser, ExportBlog urlpatterns = patterns('', url(r'^import-event/$', ImportEvent.as_view()), @@ -21,5 +21,6 @@ urlpatterns = patterns('', url(r'^export-place_conference/$', ExportPlaceConference.as_view()), url(r'^export-user/$', ExportUser.as_view()), url(r'^export-company/$', ExportCompany.as_view()), + url(r'^export-blog/$', ExportBlog.as_view()), ) diff --git a/import_xls/export_forms.py b/import_xls/export_forms.py index 28470ff9..30a87dee 100644 --- a/import_xls/export_forms.py +++ b/import_xls/export_forms.py @@ -1,11 +1,13 @@ # -*- coding: utf-8 -*- from django import forms from django.conf import settings +from django.utils import translation from theme.models import Theme, Tag from country.models import Country from organiser.models import Organiser from accounts.models import User from company.models import Company +from article.models import Article from place_exposition.models import PlaceExposition from place_conference.models import PlaceConference from django.db.models.loading import get_model @@ -149,6 +151,16 @@ class ExportCompanyForm(ExportForm): def get_fname(self): return 'companies.xls' +class ExportBlogForm(ExportForm): + model = Article + + def get_fname(self): + return 'blogs.xls' + + def get_objects(self, data): + translation.activate(data['language']) + return self.model.objects.blogs() + class ExportEventForm(forms.Form): diff --git a/meta/models.py b/meta/models.py index f00f6485..e8efbed1 100644 --- a/meta/models.py +++ b/meta/models.py @@ -7,6 +7,39 @@ from hvad.models import TranslatableModel, TranslatedFields, TranslationManager from pymorphy.django_conf import default_morph as morph from functions.signal_handlers import post_save_handler +# additional funcs +MONTHES = {'jan': _(u'январе'), 'feb': _(u'феврале'), 'mar': _(u'марте'), 'apr': _(u'апреле'), + 'may': _(u'мае'), 'jun': _(u'июне'), u'jul': _(u'июле'), 'aug': _(u'августе'), + 'sep': _(u'сентябре'), 'oct': _(u'октябре'), 'nov': _(u'ноябре'), 'dec': _(u'декабре'),} +def get_month_inflect(value, key): + return {key: MONTHES.get(value, '') } + +def get_obj_inflect(obj, key): + if translation.get_language() == 'ru': + result = {key: getattr(obj, 'inflect', '')} + else: + result = {key: getattr(obj, 'name', '')} + return result + +def get_theme_inflect(obj, key): + if translation.get_language() == 'ru': + result = {'theme_inflect': getattr(obj, 'inflect', ''), + 'theme_name': getattr(obj, 'name', '')} + else: + result = {'theme_inflect': getattr(obj, 'name', ''), + 'theme_name': getattr(obj, 'name', '')} + return result + +def get_tag_inflect(obj, key): + if translation.get_language() == 'ru': + result = {'tag_inflect': getattr(obj, 'inflect', ''), + 'tag_name': getattr(obj, 'name', '')} + else: + result = {'tag_inflect': getattr(obj, 'name', ''), + 'tag_name': getattr(obj, 'name', '')} + return result + + class MetaSetting(TranslatableModel): name = models.CharField(max_length=100, unique=True) translations = TranslatedFields( @@ -16,36 +49,34 @@ class MetaSetting(TranslatableModel): h1 = models.CharField(max_length=255, blank=True), ) - object_params = {'EXPONAME':{'name': 'name'}, - 'EXPONAME_YA':{'name': 'name', 'inflect': True}, - 'EXPOCOUNTRY':{'name': 'country'}, - 'EXPOCOUNTRY_YA':{'name': 'country', 'inflect': True}, - 'EXPOPLACE':{'name': 'place'}, - 'EXPOCITY':{'name': 'city'}, - 'EXPOTHEME':{'name': 'theme'}, - 'EXPOTAG':{'name': 'tag'}, - 'EXPOMONTH':{'name': 'month'}, - 'EXPOYEAR':{'name': 'year'}, - } - params = {} + object_params = {'object_name': 'name', 'object_title': 'main_title'} + + params = {'month': get_month_inflect, 'country': get_obj_inflect, 'city': get_obj_inflect, + 'theme': get_theme_inflect, 'tag': get_tag_inflect} monthes = {'jan': _(u'январе'), 'feb': _(u'феврале'), 'mar': _(u'марте'), 'apr': _(u'апреле'), 'may': _(u'мае'), 'jun': _(u'июне'), u'jul': _(u'июле'), 'aug': _(u'августе'), 'sep': _(u'сентябре'), 'oct': _(u'октябре'), 'nov': _(u'ноябре'), 'dec': _(u'декабре'),} + + def __unicode__(self): return self.name + def generate_meta(self, params, obj=None): """ obj must be in current language """ lang = translation.get_language() + updates = {} if obj: - params.update({'EXPONAME': getattr(obj, 'name', '')}) + for key, value in self.object_params.iteritems(): + updates.update({key: getattr(obj, value, '')}) - if params.get('month'): - month = params['month'] - params['month'] = self.monthes[month] + for key, value in params.iteritems(): + if key in self.params: + updates.update(self.params[key](value, key)) + params.update(updates) tr = self.translations.get(language_code=lang) title = tr.title.format(**params) diff --git a/meta/views.py b/meta/views.py index bcbebe11..f943355f 100644 --- a/meta/views.py +++ b/meta/views.py @@ -155,13 +155,19 @@ class MetadataMixin(object): context = super(MetadataMixin, self).get_context_data(**kwargs) meta_id = self.kwargs.get('meta_id') + if not meta_id: + meta_id = kwargs.get('meta_id') + if meta_id: try: meta_set = MetaSetting.objects.get(id=meta_id) except MetaSetting.DoesNotExist: return context params = dict(self.kwargs) - data = meta_set.generate_meta(params) + if getattr(self, 'object', None): + data = meta_set.generate_meta(params, self.object) + else: + data = meta_set.generate_meta(params) self.title = data.get('title') self.h1 = data.get('h1') diff --git a/proj/production.py b/proj/production.py index 4360eb31..9ff19ae6 100644 --- a/proj/production.py +++ b/proj/production.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Django local settings -DEBUG = True # изменить когда будет продакшн +DEBUG = False + +ALLOWED_HOSTS = ['hit.expomap.ru', '195.66.79.152', '195.66.79.145', 'expomap.ru'] DATABASES = { 'default': { diff --git a/proj/settings.py b/proj/settings.py index 06fe4c09..be6286d4 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -385,12 +385,7 @@ CALLBACK_EMAIL = 'kotzilla@ukr.net' BOOKING_AID = '333667' -""" -try: - from local import * -except ImportError, e: - from production import * -""" + ADMIN_PAGINATION = 20 CLIENT_PAGINATION = 15 TEMPLATE_DEBUG = DEBUG @@ -407,3 +402,8 @@ MONTHES = {'jan': {'value': 1, 'name': _(u'Январь')}, 'feb': {'value': 2, 'jul': {'value': 7, 'name': _(u'Июль')}, 'aug': {'value': 8, 'name': _(u'Август')}, 'sep': {'value': 9, 'name': _(u'Сентябрь')}, 'oct': {'value': 10, 'name': _(u'Октябрь')}, 'nov': {'value': 11, 'name': _(u'Ноябрь')}, 'dec': {'value': 12, 'name': _(u'Декабрь')}} + +try: + from local import * +except ImportError, e: + pass diff --git a/service/models.py b/service/models.py index 9ac38dcd..0553d370 100644 --- a/service/models.py +++ b/service/models.py @@ -31,6 +31,7 @@ class Service(TranslatableModel): ) sort = models.PositiveIntegerField(default=0, db_index=True) main_page = models.PositiveIntegerField(default=0, db_index=True) + meta_id = models.IntegerField(null=True) def __unicode__(self): diff --git a/templates/client/conference/catalog.html b/templates/client/conference/catalog.html index 08fcc6ce..bac0aa8b 100644 --- a/templates/client/conference/catalog.html +++ b/templates/client/conference/catalog.html @@ -24,7 +24,7 @@ {% block page_title %}
-

{% trans 'Конференции' %}: {{ filter_object.name }}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Конференции' %}: {{ filter_object.name }}{% endif %}

{% include 'includes/exposition/catalog_filter_period.html' %} diff --git a/templates/client/conference/catalog_theme.html b/templates/client/conference/catalog_theme.html index 1da08725..bb249f3d 100644 --- a/templates/client/conference/catalog_theme.html +++ b/templates/client/conference/catalog_theme.html @@ -49,7 +49,7 @@ {% block page_title %}
-

{% trans 'Конференции' %}: {{ filter_object.name }}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Конференции' %}: {{ filter_object.name }}{% endif %}

{% include 'includes/exposition/catalog_filter_period.html' %} diff --git a/templates/client/conference/conference_list.html b/templates/client/conference/conference_list.html index dafbc47e..9c98e09c 100644 --- a/templates/client/conference/conference_list.html +++ b/templates/client/conference/conference_list.html @@ -23,7 +23,7 @@ {% block page_title %}
-

{% trans 'Конференции' %}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Конференции' %}{% endif %}

{% include 'includes/exposition/catalog_filter_period.html' %} diff --git a/templates/client/exposition/catalog.html b/templates/client/exposition/catalog.html index 74117eb3..cb8941dc 100644 --- a/templates/client/exposition/catalog.html +++ b/templates/client/exposition/catalog.html @@ -24,7 +24,8 @@ {% block page_title %}
-

{% trans 'Выставки' %}: {{ filter_object.name }}

+ {#

{% trans 'Выставки' %}: {{ filter_object.name }}

#} +

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Выставки' %}: {{ filter_object.name }}{% endif %}

{% include 'includes/exposition/catalog_filter_period.html' %} diff --git a/templates/client/exposition/catalog_theme.html b/templates/client/exposition/catalog_theme.html index 7a727431..ab39aceb 100644 --- a/templates/client/exposition/catalog_theme.html +++ b/templates/client/exposition/catalog_theme.html @@ -49,7 +49,8 @@ {% block page_title %}
-

{% trans 'Выставки' %}: {{ filter_object.name }}

+ {#

{% trans 'Выставки' %}: {{ filter_object.name }}

#} +

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Выставки' %}: {{ filter_object.name }}{% endif %}

{% include 'includes/exposition/catalog_filter_period.html' %} diff --git a/templates/client/service/catalog.html b/templates/client/service/catalog.html index 1e90d85d..e9d7521d 100644 --- a/templates/client/service/catalog.html +++ b/templates/client/service/catalog.html @@ -22,7 +22,7 @@ {% block page_title %}
-

{% trans 'Официальный каталог выставки' %}{% if object %} {{ object.name }} {% endif %}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Официальный каталог выставки' %}{% if object %} {{ object.name }} {% endif %}{% endif %}

{% endblock %} diff --git a/templates/client/service/participation.html b/templates/client/service/participation.html index ef7f9e8d..9aca1da5 100644 --- a/templates/client/service/participation.html +++ b/templates/client/service/participation.html @@ -21,7 +21,7 @@ {% block page_title %}
-

{% trans 'Участие в выставке' %}{% if object %} {{ object.name }} {% endif %}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Участие в выставке' %}{% if object %} {{ object.name }} {% endif %}{% endif %}

{% endblock %} diff --git a/templates/client/service/remotely.html b/templates/client/service/remotely.html index 78e37758..2b4b6eb6 100644 --- a/templates/client/service/remotely.html +++ b/templates/client/service/remotely.html @@ -23,7 +23,7 @@ {% block page_title %}
-

{% trans 'Заочное посещение выставки' %}{% if object %} {{ object.name }} {% endif %}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Заочное посещение выставки' %}{% if object %} {{ object.name }} {% endif %}{% endif %}

{% endblock %} diff --git a/templates/client/service/tickets.html b/templates/client/service/tickets.html index 1778b32e..cac15dc7 100644 --- a/templates/client/service/tickets.html +++ b/templates/client/service/tickets.html @@ -22,7 +22,7 @@ {% block page_title %}
-

{% trans 'Билеты на выставку' %}{% if object %} {{ object.name }} {% endif %}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Билеты на выставку' %}{% if object %} {{ object.name }} {% endif %}{% endif %}

{% endblock %} diff --git a/templates/client/service/tour.html b/templates/client/service/tour.html index 6cdbf1e9..85580e47 100644 --- a/templates/client/service/tour.html +++ b/templates/client/service/tour.html @@ -22,7 +22,7 @@ {% block page_title %}
-

{% trans 'Посещение выставки' %} {% if object %}{{ object.name }}{% endif %}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Посещение выставки' %} {% if object %}{{ object.name }}{% endif %}{% endif %}

{% endblock %} diff --git a/templates/client/service/translator.html b/templates/client/service/translator.html index a071dda4..bb7b6f84 100644 --- a/templates/client/service/translator.html +++ b/templates/client/service/translator.html @@ -23,7 +23,7 @@ {% block page_title %}
-

{% trans 'Услуги переводчика' %}{% if object %} {% trans 'на' %} {{ object.name }} {% endif %}

+

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Услуги переводчика' %}{% if object %} {% trans 'на' %} {{ object.name }} {% endif %}{% endif %}

{% endblock %}