~cjohnston/loco-team-portal/720567

« back to all changes in this revision

Viewing changes to loco_directory/meetings/views.py

  • Committer: chrisjohnston at ubuntu
  • Date: 2011-02-17 07:31:59 UTC
  • mfrom: (383.5.1 712569-meeting-ical)
  • Revision ID: chrisjohnston@ubuntu.com-20110217073159-itnd39wjc4uctw11
Sets meetings to use python-vobject. Props Ronnie

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from userprofiles.models import UserProfile
19
19
import datetime
 
20
import vobject
20
21
 
21
22
def meeting_list(request):
22
23
    """
36
37
    filename = "%s.ics" % name.replace(' ', '-').lower()
37
38
    response = HttpResponse(mimetype='text/calendar')
38
39
    response['Content-Disposition'] = 'attachment; filename=%s' % filename.encode('ascii', 'replace')
39
 
    response.write('''BEGIN:VCALENDAR
40
 
PRODID:-//loco.ubuntu.com//EN
41
 
VERSION:2.0
42
 
CALSCALE:GREGORIAN
43
 
METHOD:PUBLISH
44
 
X-WR-TIMEZONE:UTC
45
 
''')
46
 
    response.write('X-WR-CALNAME:%s\n' % name)
47
 
    response.write('X-WR-CALDESC:%s\n' % name)
 
40
    calendar = vobject.iCalendar()
 
41
    calendar.add('prodid').value = '-//loco.ubuntu.com//EN'
 
42
    calendar.add('version').value = '2.0'
 
43
    calendar.add('calscale').value = 'GREGORIAN'
 
44
    calendar.add('method').value = 'PUBLISH'
 
45
    calendar.add('x-wr-timezone').value = 'UTC'
 
46
    calendar.add('x-wr-calname').value = name
 
47
    calendar.add('x-wr-caldesc').value = name
48
48
    for meeting in meetings:
49
 
        response.write(meeting.as_ical())
50
 
    response.write('''END:VCALENDAR''')
 
49
        meeting.as_ical(calendar)
 
50
    response.write(calendar.serialize())
 
51
    
51
52
    return response
 
53
    
52
54
 
53
55
def meeting_ical(request, team_meeting_id):
54
56
    """