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
=== modified file 'INSTALL'
--- INSTALL 2010-11-27 03:36:17 +0000
+++ INSTALL 2011-01-09 18:13:12 +0000
@@ -8,7 +8,7 @@
8 - sudo -u postgres createdb -O postgres loco_directory8 - sudo -u postgres createdb -O postgres loco_directory
99
10Generally:10Generally:
11 - sudo apt-get install python-django python-launchpadlib libjs-jquery-ui python-django-openid-auth python-django-south iso-codes gettext python-tz11 - 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
12 - cd loco_directory12 - cd loco_directory
13 - cp local_settings.py.sample local_settings.py13 - cp local_settings.py.sample local_settings.py
14# edit local_settings.py and set DATABASE_USER, DATABASE_PASSWORD, SECRET_KEY14# edit local_settings.py and set DATABASE_USER, DATABASE_PASSWORD, SECRET_KEY
1515
=== modified file 'loco_directory/events/models.py'
--- loco_directory/events/models.py 2010-12-30 19:46:26 +0000
+++ loco_directory/events/models.py 2011-01-09 18:13:12 +0000
@@ -27,21 +27,17 @@
27 def __unicode__(self):27 def __unicode__(self):
28 return self.name28 return self.name
29 29
30 def as_ical(self):30 def as_ical(self, cal):
31 """31 """
32 return a event as ical32 return a event as ical
33 """33 """
34 dtstart = str(self.date_begin).replace(' ','T', 1).replace(':','',2).replace('-','',2)34 event = cal.add('vevent')
35 dtend = str(self.date_end).replace(' ','T', 1).replace(':','',2).replace('-','',2)35 event.add('uid').value = str(self.id)
36 return '''BEGIN:VEVENT36 event.add('dtstart').value = self.date_begin
37UID:%(id)s37 event.add('dtend').value = self.date_end
38DTSTART:%(dtstart)sZ38 event.add('categories').value = ['Ubuntu Loco Team Event']
39DTEND:%(dtend)sZ39 event.add('summary').value = self.name or ''
40CATEGORIES:Ubuntu Loco Team Event40 event.add('description').value = self.description or ''
41SUMMARY:%(eventname)s
42DESCRIPTION:%(description)s
43END:VEVENT
44''' % {'id':self.id, 'dtstart':dtstart, 'dtend':dtend, 'eventname':self.name, 'description': self.description}
4541
46 def is_past(self):42 def is_past(self):
47 return self.date_end > datetime.datetime.today()43 return self.date_end > datetime.datetime.today()
4844
=== modified file 'loco_directory/events/views.py'
--- loco_directory/events/views.py 2011-01-05 16:01:17 +0000
+++ loco_directory/events/views.py 2011-01-09 18:13:12 +0000
@@ -21,6 +21,7 @@
21from common import launchpad21from common import launchpad
2222
23import datetime23import datetime
24import vobject
2425
25def event_list(request):26def event_list(request):
26 """27 """
@@ -42,18 +43,17 @@
42 filename = "%s.ics" % name.replace(' ', '-').lower()43 filename = "%s.ics" % name.replace(' ', '-').lower()
43 response = HttpResponse(mimetype='text/calendar')44 response = HttpResponse(mimetype='text/calendar')
44 response['Content-Disposition'] = 'attachment; filename=%s' % filename.encode('ascii', 'replace')45 response['Content-Disposition'] = 'attachment; filename=%s' % filename.encode('ascii', 'replace')
45 response.write('''BEGIN:VCALENDAR46 calendar = vobject.iCalendar()
46PRODID:-//loco.ubuntu.com//EN47 calendar.add('prodid').value = '-//loco.ubuntu.com//EN'
47VERSION:2.048 calendar.add('calscale').value = 'GREGORIAN'
48CALSCALE:GREGORIAN49 calendar.add('method').value = 'PUBLISH'
49METHOD:PUBLISH50 calendar.add('x-wr-timezone').value = 'UTC'
50X-WR-TIMEZONE:UTC51 calendar.add('x-wr-calname').value = name
51''')52 calendar.add('x-wr-caldesc').value = name
52 response.write('X-WR-CALNAME:%s\n' % name)
53 response.write('X-WR-CALDESC:%s\n' % name)
54 for event in events:53 for event in events:
55 response.write(event.as_ical())54 event.as_ical(calendar)
56 response.write('''END:VCALENDAR''')55 response.write(calendar.serialize())
56
57 return response57 return response
5858
59def event_ical(request, team_event_id):59def event_ical(request, team_event_id):

Subscribers

People subscribed via source and target branches