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

Proposed by Ronnie
Status: Merged
Approved by: Michael Hall
Approved revision: 394
Merged at revision: 396
Proposed branch: lp:~ronnie.vd.c/loco-team-portal/712608_ical_meetings
Merge into: lp:loco-team-portal
Diff against target: 83 lines (+34/-1)
3 files modified
loco_directory/teams/urls.py (+1/-0)
loco_directory/teams/views.py (+32/-0)
loco_directory/templates/teams/team_detail.html (+1/-1)
To merge this branch: bzr merge lp:~ronnie.vd.c/loco-team-portal/712608_ical_meetings
Reviewer Review Type Date Requested Status
LoCo Team Portal Developers Pending
Review via email: mp+50233@code.launchpad.net

Description of the change

ical link on team page is now for meetings and events

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/teams/urls.py'
2--- loco_directory/teams/urls.py 2010-12-02 09:12:22 +0000
3+++ loco_directory/teams/urls.py 2011-02-17 21:20:49 +0000
4@@ -9,5 +9,6 @@
5 url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/events', 'teams.views.team_event_list', name='team-event-list'),
6 url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/meetings/history', 'teams.views.team_meeting_history', name='team-meeting-history'),
7 url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/meetings', 'teams.views.team_meeting_list', name='team-meeting-list'),
8+ url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/ical', 'teams.views.team_ical', name='team-calendar'),
9 url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)', 'teams.views.team_detail', name='team-detail'),
10 )
11
12=== modified file 'loco_directory/teams/views.py'
13--- loco_directory/teams/views.py 2010-12-02 09:29:20 +0000
14+++ loco_directory/teams/views.py 2011-02-17 21:20:49 +0000
15@@ -18,9 +18,13 @@
16 from teams.models import Continent, Team, countries_without_continent, countries_without_continent_have_teams, teams_without_country
17 from teams.utils import merge_teams
18
19+from events.models import TeamEvent
20+from meetings.models import TeamMeeting
21+
22 import forms
23
24 import datetime
25+import vobject
26
27 def reapprovals(request):
28 teams = filter(lambda a: a.approved and a.expires_date != None,
29@@ -42,6 +46,24 @@
30 return render_to_response('teams/team_reapprovals.html',
31 context, RequestContext(request))
32
33+def as_ical(objects, name):
34+ """Return any list events as an ical"""
35+ filename = "%s.ics" % name.replace(' ', '-').lower()
36+ response = http.HttpResponse(mimetype='text/calendar')
37+ response['Content-Disposition'] = 'attachment; filename=%s' % filename.encode('ascii', 'replace')
38+ calendar = vobject.iCalendar()
39+ calendar.add('prodid').value = '-//loco.ubuntu.com//EN'
40+ calendar.add('calscale').value = 'GREGORIAN'
41+ calendar.add('method').value = 'PUBLISH'
42+ calendar.add('x-wr-timezone').value = 'UTC'
43+ calendar.add('x-wr-calname').value = name
44+ calendar.add('x-wr-caldesc').value = name
45+ for o in objects:
46+ o.as_ical(calendar)
47+ response.write(calendar.serialize())
48+
49+ return response
50+
51 def team_list(request):
52 team_list = Team.objects.all().order_by('name')
53
54@@ -56,6 +78,16 @@
55 return render_to_response('teams/team_list.html', context,
56 RequestContext(request))
57
58+def team_ical(request, team_slug):
59+ """
60+ Return a ical list with the events and meetings in ical format.
61+ """
62+ team_object = get_object_or_404(Team, lp_name=team_slug)
63+ team_events = list(TeamEvent.objects.filter(teams__lp_name=team_slug))
64+ team_meetings = list(TeamMeeting.objects.filter(teams__lp_name=team_slug))
65+ team_events.extend(team_meetings)
66+ return as_ical(team_events, team_object.name)
67+
68 def team_event_list(request, team_slug):
69 """
70 list with all team events in present and future for the given team
71
72=== modified file 'loco_directory/templates/teams/team_detail.html'
73--- loco_directory/templates/teams/team_detail.html 2011-02-17 19:30:47 +0000
74+++ loco_directory/templates/teams/team_detail.html 2011-02-17 21:20:49 +0000
75@@ -184,7 +184,7 @@
76 <li style="font-size:0.98em"><a href="{% url team-meeting-list team.lp_name %}">{% trans "All Meetings" %}</a></li>
77 <li style="font-size:0.98em"><a href="{% url team-event-history team.lp_name %}">{% trans "Past Events" %}</a></li>
78 <li style="font-size:0.98em"><a href="{% url team-events-rss team.lp_name %}">{% trans "RSS Feed" %}</a></li>
79- <li style="font-size:0.98em"><a href="{% url team-event-list-ical team.lp_name %}">{% trans "iCal Feed" %}</a></li>
80+ <li style="font-size:0.98em"><a href="{% url team-calendar team.lp_name %}">{% trans "iCal Feed" %}</a></li>
81 </ul>
82 {% if team.next_5_events_and_meetings %}
83 <ul>

Subscribers

People subscribed via source and target branches