|
|
|
|
@ -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 |
|
|
|
|
|