|
|
|
|
@ -265,36 +265,39 @@ from django.core.urlresolvers import reverse |
|
|
|
|
def download_workbook(request): |
|
|
|
|
lang = get_language() |
|
|
|
|
data = request.GET |
|
|
|
|
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])) |
|
|
|
|
|
|
|
|
|
earliest_event = qs[0].data_begin |
|
|
|
|
for i, obj in enumerate(qs, start=1): |
|
|
|
|
if obj.data_begin < earliest_event: |
|
|
|
|
earliest_event = obj.data_begin |
|
|
|
|
setattr(obj, 'number', i) |
|
|
|
|
setattr(obj, 'dates', u'%s - %s'%(obj.data_begin.strftime('%d %B %Y'),obj.data_end.strftime('%d %B %Y'))) |
|
|
|
|
setattr(obj, 'full_place', u'%s, %s, %s' % (obj.country, obj.city, getattr(obj.place, 'name', ''))) |
|
|
|
|
try: |
|
|
|
|
setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_absolute_url()) |
|
|
|
|
except: |
|
|
|
|
setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_permanent_url()) |
|
|
|
|
|
|
|
|
|
columns = ( |
|
|
|
|
'number', |
|
|
|
|
'name', |
|
|
|
|
'dates', |
|
|
|
|
'main_title', |
|
|
|
|
'full_place', |
|
|
|
|
'participation_note', |
|
|
|
|
'link') |
|
|
|
|
|
|
|
|
|
workbook = queryset_to_workbook(qs, columns, earliest_event) |
|
|
|
|
response = HttpResponse(content_type='application/vnd.ms-excel') |
|
|
|
|
response['Content-Disposition'] = 'attachment; filename="My calendar.xls"' |
|
|
|
|
workbook.save(response) |
|
|
|
|
return response |
|
|
|
|
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])) |
|
|
|
|
|
|
|
|
|
earliest_event = qs[0].data_begin |
|
|
|
|
for i, obj in enumerate(qs, start=1): |
|
|
|
|
if obj.data_begin < earliest_event: |
|
|
|
|
earliest_event = obj.data_begin |
|
|
|
|
setattr(obj, 'number', i) |
|
|
|
|
setattr(obj, 'dates', u'%s - %s'%(obj.data_begin.strftime('%d %B %Y'),obj.data_end.strftime('%d %B %Y'))) |
|
|
|
|
setattr(obj, 'full_place', u'%s, %s, %s' % (obj.country, obj.city, getattr(obj.place, 'name', ''))) |
|
|
|
|
try: |
|
|
|
|
setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_absolute_url()) |
|
|
|
|
except: |
|
|
|
|
setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_permanent_url()) |
|
|
|
|
|
|
|
|
|
columns = ( |
|
|
|
|
'number', |
|
|
|
|
'name', |
|
|
|
|
'dates', |
|
|
|
|
'main_title', |
|
|
|
|
'full_place', |
|
|
|
|
'participation_note', |
|
|
|
|
'link') |
|
|
|
|
|
|
|
|
|
workbook = queryset_to_workbook(qs, columns, earliest_event) |
|
|
|
|
response = HttpResponse(content_type='application/vnd.ms-excel') |
|
|
|
|
response['Content-Disposition'] = 'attachment; filename="My calendar.xls"' |
|
|
|
|
workbook.save(response) |
|
|
|
|
return response |
|
|
|
|
else: |
|
|
|
|
return HttpResponseRedirect(request.META.get('HTTP_REFERER'), "/profile/calendar/") |
|
|
|
|
|