fix #72
This commit is contained in:
parent
da2b91552f
commit
6f907aff7a
|
@ -328,6 +328,10 @@ class Talk(PonyConfModel):
|
||||||
def dtend(self):
|
def dtend(self):
|
||||||
return self.end_date.strftime('%Y%m%dT%H%M%SZ')
|
return self.end_date.strftime('%Y%m%dT%H%M%SZ')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dtstamp(self):
|
||||||
|
return self.updated.strftime('%Y%m%dT%H%M%SZ')
|
||||||
|
|
||||||
#@property
|
#@property
|
||||||
#def materials_name(self):
|
#def materials_name(self):
|
||||||
# return basename(self.materials.name)
|
# return basename(self.materials.name)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from django.utils.html import escape
|
||||||
from django.utils.timezone import localtime
|
from django.utils.timezone import localtime
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.template.loader import get_template
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
@ -251,8 +252,7 @@ class Program:
|
||||||
def _as_ics(self):
|
def _as_ics(self):
|
||||||
if not self.initialized:
|
if not self.initialized:
|
||||||
self._lazy_init()
|
self._lazy_init()
|
||||||
talks = [ICS_TALK.format(site=self.site, talk=talk) for talk in self.talks]
|
return get_template('cfp/planning.ics').render({'site': self.site, 'talks': self.talks})
|
||||||
return ICS_MAIN.format(site=self.site, talks='\n'.join(talks))
|
|
||||||
|
|
||||||
def render(self, output='html'):
|
def render(self, output='html'):
|
||||||
if self.cache:
|
if self.cache:
|
||||||
|
@ -267,27 +267,3 @@ class Program:
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.render()
|
return self.render()
|
||||||
|
|
||||||
|
|
||||||
# FIXME definitely the wrong place for this, but hey, other templates are already here :P
|
|
||||||
|
|
||||||
ICS_MAIN = """BEGIN:VCALENDAR
|
|
||||||
PRODID:-//{site.domain}//{site.name}//FR
|
|
||||||
X-WR-CALNAME:PonyConf
|
|
||||||
X-WR-TIMEZONE:Europe/Paris
|
|
||||||
VERSION:2.0
|
|
||||||
CALSCALE:GREGORIAN
|
|
||||||
METHOD:PUBLISH
|
|
||||||
{talks}
|
|
||||||
END:VCALENDAR"""
|
|
||||||
|
|
||||||
ICS_TALK = """BEGIN:VEVENT
|
|
||||||
DTSTART:{talk.dtstart}
|
|
||||||
DTEND:{talk.dtend}
|
|
||||||
SUMMARY:{talk.title}
|
|
||||||
LOCATION:{talk.room}
|
|
||||||
STATUS: CONFIRMED
|
|
||||||
DESCRIPTION:{talk.description}
|
|
||||||
UID:{site.domain}/{talk.id}
|
|
||||||
END:VEVENT
|
|
||||||
"""
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
PRODID:-//{{ site.domain }}//{{ site.name }}//FR
|
||||||
|
X-WR-CALNAME:PonyConf
|
||||||
|
X-WR-TIMEZONE:Europe/Paris
|
||||||
|
VERSION:2.0
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
METHOD:PUBLISH
|
||||||
|
{% for talk in talks %}
|
||||||
|
BEGIN:VEVENT
|
||||||
|
DTSTAMP:{{ talk.dtstamp }}
|
||||||
|
DTSTART:{{ talk.dtstart }}
|
||||||
|
DTEND:{{ talk.dtend }}
|
||||||
|
SUMMARY:{{ talk.title }}
|
||||||
|
LOCATION:{{ talk.room }}
|
||||||
|
STATUS:{% if talk.accepted %}CONFIRMED{% else %}TENTATIVE{% endif %}
|
||||||
|
DESCRIPTION:{{ talk.description }}
|
||||||
|
UID:{{ site.domain }}/{{ talk.id }}
|
||||||
|
END:VEVENT{% endfor %}
|
||||||
|
END:VCALENDAR
|
14
cfp/views.py
14
cfp/views.py
|
@ -1,3 +1,4 @@
|
||||||
|
from math import ceil
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
|
@ -480,7 +481,18 @@ def schedule(request, program_format, pending, cache, template):
|
||||||
elif program_format == 'xml':
|
elif program_format == 'xml':
|
||||||
return HttpResponse(program.render('xml'), content_type="application/xml")
|
return HttpResponse(program.render('xml'), content_type="application/xml")
|
||||||
elif program_format == 'ics':
|
elif program_format == 'ics':
|
||||||
return HttpResponse(program.render('ics'), content_type="text/calendar")
|
response = HttpResponse('', content_type='text/plain')
|
||||||
|
response['Content-Disposition'] = 'attachment; filename="planning.ics"'
|
||||||
|
ics = []
|
||||||
|
for line in program.render('ics').split('\n'):
|
||||||
|
line = line.strip()
|
||||||
|
if len(line) < 50:
|
||||||
|
ics.append(line)
|
||||||
|
else: # https://icalendar.org/iCalendar-RFC-5545/3-1-content-lines.html
|
||||||
|
for i in range(ceil(len(line) / 50)):
|
||||||
|
ics.append((' ' if i > 0 else '') + line[i * 50:(i + 1) * 50])
|
||||||
|
response.write('\r\n'.join([line for line in ics if line]))
|
||||||
|
return response
|
||||||
else:
|
else:
|
||||||
raise Http404(_("Format '%s' not available" % program_format))
|
raise Http404(_("Format '%s' not available" % program_format))
|
||||||
|
|
||||||
|
|
|
@ -4,30 +4,26 @@
|
||||||
#
|
#
|
||||||
# pip-compile --output-file requirements-dev.txt requirements-dev.in
|
# pip-compile --output-file requirements-dev.txt requirements-dev.in
|
||||||
#
|
#
|
||||||
-e git+git://github.com/Nim65s/django-YummyEmailOrUsernameInsensitiveAuth.git#egg=django-yeouia
|
|
||||||
bleach==2.0.0
|
bleach==2.0.0
|
||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
decorator==4.0.11 # via ipython
|
decorator==4.1.2 # via ipython
|
||||||
django-appconf==1.0.2 # via django-avatar, django-select2
|
django-appconf==1.0.2 # via django-select2
|
||||||
django-autoslug==1.9.3
|
django-autoslug==1.9.3
|
||||||
django-avatar==4.0.0
|
django-bootstrap3==9.0.0
|
||||||
django-bootstrap3==8.2.3
|
|
||||||
django-bower==5.2.0
|
django-bower==5.2.0
|
||||||
django-colorful==1.2
|
django-colorful==1.2
|
||||||
|
django-crispy-forms==1.6.1
|
||||||
django-debug-toolbar==1.8
|
django-debug-toolbar==1.8
|
||||||
django-extensions==1.8.1
|
django-extensions==1.9.1
|
||||||
django-registration-redux==1.6
|
django-select2==5.11.1
|
||||||
django-select2==5.10.0
|
django==1.11.5
|
||||||
django==1.11.3
|
|
||||||
html5lib==0.999999999 # via bleach
|
html5lib==0.999999999 # via bleach
|
||||||
ipython==6.1.0
|
ipython==6.1.0
|
||||||
jedi==0.10.2 # via ipython
|
jedi==0.10.2 # via ipython
|
||||||
markdown==2.6.8
|
markdown==2.6.9
|
||||||
olefile==0.44 # via pillow
|
|
||||||
pexpect==4.2.1 # via ipython
|
pexpect==4.2.1 # via ipython
|
||||||
pickleshare==0.7.4 # via ipython
|
pickleshare==0.7.4 # via ipython
|
||||||
pillow==4.2.1 # via django-avatar
|
prompt-toolkit==1.0.15 # via ipython
|
||||||
prompt-toolkit==1.0.14 # via ipython
|
|
||||||
pygments==2.2.0 # via ipython
|
pygments==2.2.0 # via ipython
|
||||||
pytz==2017.2 # via django
|
pytz==2017.2 # via django
|
||||||
simplegeneric==0.8.1 # via ipython
|
simplegeneric==0.8.1 # via ipython
|
||||||
|
@ -36,6 +32,3 @@ sqlparse==0.2.3 # via django-debug-toolbar
|
||||||
traitlets==4.3.2 # via ipython
|
traitlets==4.3.2 # via ipython
|
||||||
wcwidth==0.1.7 # via prompt-toolkit
|
wcwidth==0.1.7 # via prompt-toolkit
|
||||||
webencodings==0.5.1 # via html5lib
|
webencodings==0.5.1 # via html5lib
|
||||||
|
|
||||||
# The following packages are considered to be unsafe in a requirements file:
|
|
||||||
# setuptools # via html5lib, ipython
|
|
||||||
|
|
|
@ -3,13 +3,10 @@ django<1.12
|
||||||
django-autoslug
|
django-autoslug
|
||||||
django-bootstrap3
|
django-bootstrap3
|
||||||
django-bower
|
django-bower
|
||||||
django-registration-redux
|
django-crispy-forms
|
||||||
django-select2
|
django-select2
|
||||||
django-avatar
|
|
||||||
django-colorful
|
django-colorful
|
||||||
|
|
||||||
markdown
|
markdown
|
||||||
bleach
|
bleach
|
||||||
chardet
|
chardet
|
||||||
|
|
||||||
-e git://github.com/Nim65s/django-YummyEmailOrUsernameInsensitiveAuth.git#egg=django-yeouia
|
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
django<1.12
|
#
|
||||||
|
# This file is autogenerated by pip-compile
|
||||||
django-autoslug
|
# To update, run:
|
||||||
django-bootstrap3
|
#
|
||||||
django-bower
|
# pip-compile --output-file requirements.txt requirements.in
|
||||||
django-crispy-forms
|
#
|
||||||
django-select2
|
bleach==2.0.0
|
||||||
django-colorful
|
chardet==3.0.4
|
||||||
|
django-appconf==1.0.2 # via django-select2
|
||||||
markdown
|
django-autoslug==1.9.3
|
||||||
bleach
|
django-bootstrap3==9.0.0
|
||||||
chardet
|
django-bower==5.2.0
|
||||||
|
django-colorful==1.2
|
||||||
|
django-crispy-forms==1.6.1
|
||||||
|
django-select2==5.11.1
|
||||||
|
django==1.11.5
|
||||||
|
html5lib==0.999999999 # via bleach
|
||||||
|
markdown==2.6.9
|
||||||
|
pytz==2017.2 # via django
|
||||||
|
six==1.10.0 # via bleach, django-bower, html5lib
|
||||||
|
webencodings==0.5.1 # via html5lib
|
||||||
|
|
Loading…
Reference in New Issue