1459: Этап №5: Дополнительно - Мета-теги

доп при сдаче этапа:
В шаблонизатор еще надо добавить даты %object_dates%  (с 1 по 3 апреля)  + название места %object_place%
remotes/origin/stage5
Alexander Burdeiny 10 years ago
parent 693b14292c
commit 73e72dfc21
  1. 52
      functions/model_mixin.py
  2. 2
      meta/models.py
  3. 2
      templates/c_admin/meta/meta_setting.html
  4. 18
      templates/client/includes/show_date_block.html

@ -1,12 +1,17 @@
# -*- coding: utf-8 -*-
import copy
from django.db.models import Q
import calendar as python_calendar
from pytils.dt import ru_strftime
from django.conf import settings
from django.db.models import Q
from django.utils.translation import ugettext as _
from django.utils.translation import get_language
from hvad.utils import get_translation, set_cached_translation, get_cached_translation
from functions.translate import fill_with_signal
import calendar as python_calendar
from service.models import Service
from photologue.models import Gallery
from django.utils.translation import ugettext as _
class ExpoMixin(object):
@ -30,6 +35,47 @@ class ExpoMixin(object):
class EventMixin(object):
@property
def get_dates(self):
lang = get_language()
if self.data_end and self.data_begin:
delta = self.data_end - self.data_begin
if delta.days > 28 and self.data_end.month == self.data_begin.month:
return self.data_begin.strftime('%B')
elif delta.days < 1:
if lang == 'ru':
return ru_strftime("%d %B %Y", date=self.data_begin, inflected=True)
return self.data_begin
if self.data_begin.month != self.data_end.month:
if lang == 'ru':
start = ru_strftime("%d %B", date=self.data_begin, inflected=True)
else:
start = u'{month} {day}'.format(
month=self.data_begin.strftime('%B'),
day=self.data_begin.day)
else:
start = self.data_begin.day
if lang == 'ru':
end = ru_strftime("%d %B", date=self.data_end, inflected=True)
else:
end = u'{month} {day}'.format(
month=self.data_end.strftime('%B'),
day=self.data_end.day)
return _(u'c {start} по {end}').format(start=start, end=end)
if lang == 'ru':
return ru_strftime("%d %B %Y", date=self.data_begin, inflected=True)
return self.data_begin
@property
def get_place_name(self):
tr = get_cached_translation(self.place)
if tr is None:
tr = get_translation(self.place)
set_cached_translation(self.place, tr)
return self.place.name
def get_permanent_url(self):
url = '%s%s/'%(self.get_catalog_url(), self.url)
return url

@ -66,6 +66,8 @@ class MetaSetting(TranslatableModel):
'object_title_l': lambda obj: getattr(obj, 'main_title', '')[:1].lower() + getattr(obj, 'main_title', '')[1:] if getattr(obj, 'main_title', None) else '',
'city': 'city',
'country': 'country',
'object_dates': 'get_dates',
'object_place': 'get_place_name'
}
# default params

@ -24,6 +24,8 @@
<br>{object_name} - название события (выставки/конференции)
<br>{object_title} - краткое описание события (выставки/конференции)/ заголовок новости или статьи
<br>{object_title_l} - краткое описание события (выставки/конференции)/ заголовок новости или статьи (с маленькой буквы)
<br>{object_dates} - даты проведения события (выставки/конференции)
<br>{object_place} - место проведения события (выставки/конференции)
<br>{city} - город
<br>{country} - страна
</div>

@ -21,6 +21,7 @@
{% if obj.data_end %}
{% trans 'с' %}
{% ifnotequal obj.data_begin|date:"F" obj.data_end|date:"F" %}
{% ifequal LANGUAGE_CODE 'ru' %}
{{ obj.data_begin|ru_strftime:"%d %B" }}
@ -28,12 +29,17 @@
{{ obj.data_begin|date:"F j" }}
{% endifequal %}
{% else %}
{{ obj.data_begin|date:"j" }}{% endifnotequal %} {% trans 'по' %}
{% ifequal LANGUAGE_CODE 'ru' %}
{{ obj.data_end|ru_strftime:"%d %B" }}
{% else %}
{{ obj.data_end }}
{% endifequal %}
{{ obj.data_begin|date:"j" }}
{% endifnotequal %}
{% trans 'по' %}
{% ifequal LANGUAGE_CODE 'ru' %}
{{ obj.data_end|ru_strftime:"%d %B" }}
{% else %}
{{ obj.data_end }}
{% endifequal %}
{% else %}
{{ obj.data_begin }}
{% endif %}

Loading…
Cancel
Save