Permalink
Browse files

Check to see if a presentation has a slot before creating an iCal event.

  • Loading branch information...
1 parent 50c554e commit 2ccc2460a713603d7e6b9cee2b2a6366bf4a17e8 @lukeman lukeman committed Mar 7, 2011
Showing with 10 additions and 9 deletions.
  1. +10 −9 pycon_project/apps/schedule/views.py
@@ -479,15 +479,16 @@ def schedule_user_bookmarks(request, user_id, user_hash):
for bookmark in bookmarks:
p = bookmark.presentation
- event = Event()
- event.add("summary", p.title)
- event.add("dtstart", p.slot.start)
- event.add("dtend", p.slot.end)
- event.add("dtstamp", datetime.datetime.utcnow())
- event.add("description", p.speaker.name + "\n\n" + p.description)
- event.add("location", p.slot.track)
- event["uid"] = str(p.pk) + "-2011.us.pycon.org"
- cal.add_component(event)
+ if p.slot is not None:
+ event = Event()
+ event.add("summary", p.title)
+ event.add("dtstart", p.slot.start)
+ event.add("dtend", p.slot.end)
+ event.add("dtstamp", datetime.datetime.utcnow())
+ event.add("description", p.speaker.name + "\n\n" + p.description)
+ event.add("location", p.slot.track)
+ event["uid"] = str(p.pk) + "-2011.us.pycon.org"
+ cal.add_component(event)
response = HttpResponse(cal.as_string(), content_type="text/calendar")
response["Content-Disposition"] = "filename=pycon2011-%s-bookmarks.ics" % user.username.encode("utf-8")

0 comments on commit 2ccc246

Please sign in to comment.