diff --git a/core/views.py b/core/views.py index cd5ec104..5558fda8 100644 --- a/core/views.py +++ b/core/views.py @@ -79,6 +79,7 @@ class PlaceListView(ListView): template_name = 'place_catalog_test.html' model = 'places' search_form = PlaceSearchForm + order = 'data_begin' def get_params(self): model_names = {'places': _(u'Места')} diff --git a/exposition/views.py b/exposition/views.py index a007bdf8..420f25b9 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -50,6 +50,7 @@ class ExpositionView(ExpoListView): model = Exposition template_name = 'event_catalog.html' search_form = ExpositionSearchForm + order = 'data_begin' def get_context_data(self, **kwargs): context = super(ExpositionView, self).get_context_data(**kwargs) diff --git a/functions/custom_views.py b/functions/custom_views.py index 06898b90..b11dd4ce 100644 --- a/functions/custom_views.py +++ b/functions/custom_views.py @@ -226,6 +226,7 @@ class ExpoListView(ExpoMixin, ListView): params = None single_page = False search_form = None + order = None def get_queryset(self): query = self.model.objects.all() @@ -284,8 +285,10 @@ class ExpoListView(ExpoMixin, ListView): self.params = params - - return query.order_by('data_begin') + if self.order: + return query.order_by(self.order) + else: + return query def get_context_data(self, **kwargs): context = super(ExpoListView, self).get_context_data(**kwargs) diff --git a/media/imgs/cl-logo-3.png b/media/imgs/cl-logo-3.png deleted file mode 100644 index 3783a0d7..00000000 Binary files a/media/imgs/cl-logo-3.png and /dev/null differ diff --git a/media/import/.~lock.expositions_ru.xlsx# b/media/import/.~lock.expositions_ru.xlsx# new file mode 100644 index 00000000..1254c366 --- /dev/null +++ b/media/import/.~lock.expositions_ru.xlsx# @@ -0,0 +1 @@ +kotzilla ,kotzilla,kotzilla-Satellite-L300,27.05.2014 19:59,file:///home/kotzilla/.config/libreoffice/3; \ No newline at end of file diff --git a/media/import/.~lock.places_en.xlsx# b/media/import/.~lock.places_en.xlsx# deleted file mode 100644 index 59fbea56..00000000 --- a/media/import/.~lock.places_en.xlsx# +++ /dev/null @@ -1 +0,0 @@ -kotzilla ,kotzilla,kotzilla-Satellite-L300,27.05.2014 17:23,file:///home/kotzilla/.config/libreoffice/3; \ No newline at end of file diff --git a/media/import/.~lock.places_en123.xlsx# b/media/import/.~lock.places_en123.xlsx# deleted file mode 100644 index 59fbea56..00000000 --- a/media/import/.~lock.places_en123.xlsx# +++ /dev/null @@ -1 +0,0 @@ -kotzilla ,kotzilla,kotzilla-Satellite-L300,27.05.2014 17:23,file:///home/kotzilla/.config/libreoffice/3; \ No newline at end of file diff --git a/media/import/.~lock.places_ru.xlsx# b/media/import/.~lock.places_ru.xlsx# new file mode 100644 index 00000000..e09b85da --- /dev/null +++ b/media/import/.~lock.places_ru.xlsx# @@ -0,0 +1 @@ +kotzilla ,kotzilla,kotzilla-Satellite-L300,27.05.2014 19:16,file:///home/kotzilla/.config/libreoffice/3; \ No newline at end of file diff --git a/settings/templatetags/template_filters.py b/settings/templatetags/template_filters.py index 814bb67b..00da2f24 100644 --- a/settings/templatetags/template_filters.py +++ b/settings/templatetags/template_filters.py @@ -99,4 +99,21 @@ def in_calendar(event, user): if event in calendar.get_events(): return True - return False \ No newline at end of file + return False + +from datetime import datetime, timedelta +from django import template +from django.utils.timesince import timesince + + + +@register.filter +def timesince_exp(value, date=None): + """ + return timesince() if value is more than old. Return value otherwise + """ + delta = timedelta(days=28) + d = date -value + if d>delta: + return True + return False diff --git a/templates/client/includes/show_date_block.html b/templates/client/includes/show_date_block.html index 2664bb57..608d948d 100644 --- a/templates/client/includes/show_date_block.html +++ b/templates/client/includes/show_date_block.html @@ -1,17 +1,22 @@ {% load i18n %} +{% load template_filters %} + + +{% if obj.data_begin|timesince_exp:obj.data_end %} -{% if obj.data_begin|timesince:obj.data_end > "4 week" %} {{ obj.data_begin|date:"F" }} + {% else %} {% if obj.data_begin|timesince:obj.data_end < "1 day" %} {{ obj.data_begin }} {% else %} {% if obj.data_end %} - {% trans 'с' %} {{ obj.data_begin|date:"j" }} {% trans 'по' %} {{ obj.data_end }} + {% trans 'с' %}{% ifnotequal obj.data_begin|date:"F" obj.data_end|date:"F" %} {{ obj.data_begin|date:"j F" }}{% else %} {{ obj.data_begin|date:"j" }}{% endifnotequal %} {% trans 'по' %} {{ obj.data_end }} {% else %} {{ obj.data_begin }} {% endif %} {% endif %} -{% endif %} \ No newline at end of file +{% endif %} +