From 8c17d9417e7624ccbdde2c1416bfae22ee2b01fb Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 28 Oct 2015 17:26:19 +0200 Subject: [PATCH] calendar improvement --- core/utils.py | 4 ++-- core/views.py | 21 +++++++++++++-------- templates/client/accounts/calendar.html | 22 ++++++++++++++++++---- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/core/utils.py b/core/utils.py index b3f04ee6..442325fe 100644 --- a/core/utils.py +++ b/core/utils.py @@ -83,13 +83,13 @@ def queryset_to_workbook(queryset, columns, report_date = None): 'pattern: pattern solid, fore_color gray_ega;', ) odd_style = xlwt.Style.easyxf( - 'font: name Calibri, height 300, bold False;' + 'font: name Calibri, height 240, bold False;' 'borders: left thin, right thin, top thin, bottom thin;' 'alignment: horizontal center, vertical center, wrap True;' 'pattern: pattern solid, fore_color white;', ) even_style = xlwt.Style.easyxf( - 'font: name Calibri, height 300, bold False;' + 'font: name Calibri, height 240, bold False;' 'borders: left thin, right thin, top thin, bottom thin;' 'alignment: horizontal center, vertical center, wrap True;' 'pattern: pattern solid, fore_color silver_ega;', diff --git a/core/views.py b/core/views.py index d762dc01..08ecb20c 100644 --- a/core/views.py +++ b/core/views.py @@ -266,13 +266,18 @@ def download_workbook(request): lang = get_language() data = request.GET if data: - qs = [] - for i,obj in enumerate(data): - if data.get('data[%i][name]' % i) == 'expo': - qs.append(Exposition.objects.language(lang).get(id=data['data[%i][value]'%i])) - elif data.get('data[%i][name]' % i) == 'conf': - qs.append(Conference.objects.language(lang).get(id=data['data[%i][value]'%i])) - + if data.get('filter') == u'future': + qs = request.user.calendar.get_events() + qs = [event for event in qs if event.data_begin > datetime.date.today()] + else: + qs = [] + for i,obj in enumerate(data): + if data.get('data[%i][name]' % i) == 'expo': + qs.append(Exposition.objects.language(lang).get(id=data['data[%i][value]'%i])) + elif data.get('data[%i][name]' % i) == 'conf': + qs.append(Conference.objects.language(lang).get(id=data['data[%i][value]'%i])) + if not qs: + return HttpResponseRedirect("/profile/calendar/?message=empty") earliest_event = qs[0].data_begin for i, obj in enumerate(qs, start=1): if obj.data_begin < earliest_event: @@ -305,4 +310,4 @@ def download_workbook(request): workbook.save(response) return response else: - return HttpResponseRedirect(request.META.get('HTTP_REFERER'), "/profile/calendar/") + return HttpResponseRedirect("/profile/calendar/") diff --git a/templates/client/accounts/calendar.html b/templates/client/accounts/calendar.html index 6a1f8502..36e0eb31 100644 --- a/templates/client/accounts/calendar.html +++ b/templates/client/accounts/calendar.html @@ -20,14 +20,18 @@ {% block content_list %}
{% with days=days events=events current_day=current_day %} - {% include 'includes/accounts/calendar_table.html' %} + {% include 'client/includes/accounts/calendar_table.html' %} {% endwith %}
{% if events|length > 0 %}
-
{{ days.15|date:"F"}}’{{ days.15|date:"y"}}
+
{{ days.15|date:"F"}}’{{ days.15|date:"y"}} +
+ +
+
{% include 'client/includes/accounts/calendar_list.html' with events=events %}
@@ -35,8 +39,8 @@
{% trans 'Все / выделенные:' %}