~ronnie.vd.c/loco-team-portal/loco-map-list

« back to all changes in this revision

Viewing changes to loco_directory/events/views.py

  • Committer: Ronnie
  • Date: 2010-12-18 12:40:52 UTC
  • mto: This revision was merged to the branch mainline in revision 358.
  • Revision ID: peter.puk@gmail.com-20101218124052-mm82xx7dx3eg8l4y
Calendars are now created with the python-vobject library\n\nThere should be no import error anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from common import launchpad
21
21
 
22
22
import datetime
 
23
import vobject
23
24
 
24
25
def event_list(request):
25
26
    """
41
42
    filename = "%s.ics" % name.replace(' ', '-').lower()
42
43
    response = HttpResponse(mimetype='text/calendar')
43
44
    response['Content-Disposition'] = 'attachment; filename=%s' % filename.encode('ascii', 'replace')
44
 
    response.write('''BEGIN:VCALENDAR
45
 
PRODID:-//loco.ubuntu.com//EN
46
 
VERSION:2.0
47
 
CALSCALE:GREGORIAN
48
 
METHOD:PUBLISH
49
 
X-WR-TIMEZONE:UTC
50
 
''')
51
 
    response.write('X-WR-CALNAME:%s\n' % name)
52
 
    response.write('X-WR-CALDESC:%s\n' % name)
 
45
    calendar = vobject.iCalendar()
 
46
    calendar.add('prodid').value = '-//loco.ubuntu.com//EN'
 
47
    calendar.add('calscale').value = 'GREGORIAN'
 
48
    calendar.add('method').value = 'PUBLISH'
 
49
    calendar.add('x-wr-timezone').value = 'UTC'
 
50
    calendar.add('x-wr-calname').value = name
 
51
    calendar.add('x-wr-caldesc').value = name
53
52
    for event in events:
54
 
        response.write(event.as_ical())
55
 
    response.write('''END:VCALENDAR''')
 
53
        event.as_ical(calendar)
 
54
    response.write(calendar.serialize())
 
55
    
56
56
    return response
57
57
 
58
58
def event_ical(request, team_event_id):