Merge lp:~ronnie.vd.c/loco-team-portal/623288 into lp:loco-team-portal

Proposed by Ronnie
Status: Merged
Approved by: Chris Johnston
Approved revision: 346
Merged at revision: 358
Proposed branch: lp:~ronnie.vd.c/loco-team-portal/623288
Merge into: lp:loco-team-portal
Diff against target: 87 lines (+20/-24)
3 files modified
INSTALL (+1/-1)
loco_directory/events/models.py (+8/-12)
loco_directory/events/views.py (+11/-11)
To merge this branch: bzr merge lp:~ronnie.vd.c/loco-team-portal/623288
Reviewer Review Type Date Requested Status
Adnane Belmadiaf Approve
Chris Johnston Needs Fixing
Review via email: mp+44127@code.launchpad.net

Description of the change

Calendar suppport is now trough the python-vobject library

To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) wrote :

I get the following when clicking the iCal icon next to team events on the main page.

Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  100. response = callback(request, *callback_args, **callback_kwargs)
File "/home/chris/Dropbox/Projects/loco-directory/current/loco_directory/events/views.py" in teams_event_list_ical
  78. return event_list_ical(TeamEvent.objects.all(), 'All Ubuntu LoCo Team Events')
File "/home/chris/Dropbox/Projects/loco-directory/current/loco_directory/events/views.py" in event_list_ical
  55. response.write(calendar.serialize())
File "/usr/lib/pymodules/python2.6/vobject/base.py" in serialize
  186. return behavior.serialize(self, buf, lineLength, validate)
File "/usr/lib/pymodules/python2.6/vobject/behavior.py" in serialize
  157. out = base.defaultSerialize(transformed, buf, lineLength)
File "/usr/lib/pymodules/python2.6/vobject/base.py" in defaultSerialize
  947. child.serialize(outbuf, lineLength, validate=False)
File "/usr/lib/pymodules/python2.6/vobject/base.py" in serialize
  186. return behavior.serialize(self, buf, lineLength, validate)
File "/usr/lib/pymodules/python2.6/vobject/behavior.py" in serialize
  157. out = base.defaultSerialize(transformed, buf, lineLength)
File "/usr/lib/pymodules/python2.6/vobject/base.py" in defaultSerialize
  947. child.serialize(outbuf, lineLength, validate=False)
File "/usr/lib/pymodules/python2.6/vobject/base.py" in serialize
  186. return behavior.serialize(self, buf, lineLength, validate)
File "/usr/lib/pymodules/python2.6/vobject/behavior.py" in serialize
  157. out = base.defaultSerialize(transformed, buf, lineLength)
File "/usr/lib/pymodules/python2.6/vobject/base.py" in defaultSerialize
  953. if obj.behavior and not startedEncoded: obj.behavior.encode(obj)
File "/usr/lib/pymodules/python2.6/vobject/icalendar.py" in encode
  609. line.value = backslashEscape(line.value)
File "/usr/lib/pymodules/python2.6/vobject/base.py" in backslashEscape
  1137. s=s.replace("\\","\\\\").replace(";","\;").replace(",","\,")

Exception Type: AttributeError at /events/team/ical/
Exception Value: 'NoneType' object has no attribute 'replace'

review: Needs Fixing
Revision history for this message
Adnane Belmadiaf (daker) wrote :

I can't really reproduce it, i have tested all the links, and they all work for me.

review: Approve
346. By Ronnie

Fixed NoneType error

Revision history for this message
Chris Johnston (cjohnston) wrote :

Confirmed not able to run. Also able to get Ronnie to reproduce the error.

review: Needs Fixing
Revision history for this message
Adnane Belmadiaf (daker) wrote :

Works fine for me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'INSTALL'
2--- INSTALL 2010-11-27 03:36:17 +0000
3+++ INSTALL 2011-01-09 18:13:12 +0000
4@@ -8,7 +8,7 @@
5 - sudo -u postgres createdb -O postgres loco_directory
6
7 Generally:
8- - sudo apt-get install python-django python-launchpadlib libjs-jquery-ui python-django-openid-auth python-django-south iso-codes gettext python-tz
9+ - sudo apt-get install python-django python-launchpadlib libjs-jquery-ui python-django-openid-auth python-django-south iso-codes gettext python-tz python-vobject
10 - cd loco_directory
11 - cp local_settings.py.sample local_settings.py
12 # edit local_settings.py and set DATABASE_USER, DATABASE_PASSWORD, SECRET_KEY
13
14=== modified file 'loco_directory/events/models.py'
15--- loco_directory/events/models.py 2010-12-30 19:46:26 +0000
16+++ loco_directory/events/models.py 2011-01-09 18:13:12 +0000
17@@ -27,21 +27,17 @@
18 def __unicode__(self):
19 return self.name
20
21- def as_ical(self):
22+ def as_ical(self, cal):
23 """
24 return a event as ical
25 """
26- dtstart = str(self.date_begin).replace(' ','T', 1).replace(':','',2).replace('-','',2)
27- dtend = str(self.date_end).replace(' ','T', 1).replace(':','',2).replace('-','',2)
28- return '''BEGIN:VEVENT
29-UID:%(id)s
30-DTSTART:%(dtstart)sZ
31-DTEND:%(dtend)sZ
32-CATEGORIES:Ubuntu Loco Team Event
33-SUMMARY:%(eventname)s
34-DESCRIPTION:%(description)s
35-END:VEVENT
36-''' % {'id':self.id, 'dtstart':dtstart, 'dtend':dtend, 'eventname':self.name, 'description': self.description}
37+ event = cal.add('vevent')
38+ event.add('uid').value = str(self.id)
39+ event.add('dtstart').value = self.date_begin
40+ event.add('dtend').value = self.date_end
41+ event.add('categories').value = ['Ubuntu Loco Team Event']
42+ event.add('summary').value = self.name or ''
43+ event.add('description').value = self.description or ''
44
45 def is_past(self):
46 return self.date_end > datetime.datetime.today()
47
48=== modified file 'loco_directory/events/views.py'
49--- loco_directory/events/views.py 2011-01-05 16:01:17 +0000
50+++ loco_directory/events/views.py 2011-01-09 18:13:12 +0000
51@@ -21,6 +21,7 @@
52 from common import launchpad
53
54 import datetime
55+import vobject
56
57 def event_list(request):
58 """
59@@ -42,18 +43,17 @@
60 filename = "%s.ics" % name.replace(' ', '-').lower()
61 response = HttpResponse(mimetype='text/calendar')
62 response['Content-Disposition'] = 'attachment; filename=%s' % filename.encode('ascii', 'replace')
63- response.write('''BEGIN:VCALENDAR
64-PRODID:-//loco.ubuntu.com//EN
65-VERSION:2.0
66-CALSCALE:GREGORIAN
67-METHOD:PUBLISH
68-X-WR-TIMEZONE:UTC
69-''')
70- response.write('X-WR-CALNAME:%s\n' % name)
71- response.write('X-WR-CALDESC:%s\n' % name)
72+ calendar = vobject.iCalendar()
73+ calendar.add('prodid').value = '-//loco.ubuntu.com//EN'
74+ calendar.add('calscale').value = 'GREGORIAN'
75+ calendar.add('method').value = 'PUBLISH'
76+ calendar.add('x-wr-timezone').value = 'UTC'
77+ calendar.add('x-wr-calname').value = name
78+ calendar.add('x-wr-caldesc').value = name
79 for event in events:
80- response.write(event.as_ical())
81- response.write('''END:VCALENDAR''')
82+ event.as_ical(calendar)
83+ response.write(calendar.serialize())
84+
85 return response
86
87 def event_ical(request, team_event_id):

Subscribers

People subscribed via source and target branches