Ronnie has proposed merging lp:~ronnie.vd.c/loco-directory/712608_ical_meetings
into lp:loco-directory.
Requested reviews:
loco-directory-dev (loco-directory-dev)
Related bugs:
#712608 ical link on team_detail page should also contain meetings
https://bugs.launchpad.net/bugs/712608
For more details, see:
https://code.launchpad.net/~ronnie.vd.c/loco-directory/712608_ical_meetings/+merge/50233
ical link on team page is now for meetings and events
--
https://code.launchpad.net/~ronnie.vd.c/loco-directory/712608_ical_meetings/+merge/50233
Your team loco-directory-dev is requested to review the proposed merge of
lp:~ronnie.vd.c/loco-directory/712608_ical_meetings into lp:loco-directory.
=== modified file 'loco_directory/teams/urls.py'
--- loco_directory/teams/urls.py 2010-12-02 09:12:22 +0000
+++ loco_directory/teams/urls.py 2011-02-17 21:20:16 +0000
@@ -9,5 +9,6 @@
url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/events', 'teams.views.team_event_list', name='team-event-list'),
url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/meetings/history', 'teams.views.team_meeting_history', name='team-meeting-history'),
url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/meetings', 'teams.views.team_meeting_list', name='team-meeting-list'),
+ url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/ical', 'teams.views.team_ical', name='team-calendar'),
url(r'(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)', 'teams.views.team_detail', name='team-detail'),
)
=== modified file 'loco_directory/teams/views.py'
--- loco_directory/teams/views.py 2010-12-02 09:29:20 +0000
+++ loco_directory/teams/views.py 2011-02-17 21:20:16 +0000
@@ -18,9 +18,13 @@
from teams.models import Continent, Team, countries_without_continent, countries_without_continent_have_teams, teams_without_country
from teams.utils import merge_teams
+from events.models import TeamEvent
+from meetings.models import TeamMeeting
+
import forms
import datetime
+import vobject
def reapprovals(request):
teams = filter(lambda a: a.approved and a.expires_date != None,
@@ -42,6 +46,24 @@
return render_to_response('teams/team_reapprovals.html',
context, RequestContext(request))
+def as_ical(objects, name):
+ """Return any list events as an ical"""
+ filename = "%s.ics" % name.replace(' ', '-').lower()
+ response = http.HttpResponse(mimetype='text/calendar')
+ response['Content-Disposition'] = 'attachment; filename=%s' % filename.encode('ascii', 'replace')
+ calendar = vobject.iCalendar()
+ calendar.add('prodid').value = '-//loco.ubuntu.com//EN'
+ calendar.add('calscale').value = 'GREGORIAN'
+ calendar.add('method').value = 'PUBLISH'
+ calendar.add('x-wr-timezone').value = 'UTC'
+ calendar.add('x-wr-calname').value = name
+ calendar.add('x-wr-caldesc').value = name
+ for o in objects:
+ o.as_ical(calendar)
+ response.write(calendar.serialize())
+
+ return response
+
def team_list(request):
team_list = Team.objects.all().order_by('name')
@@ -56,6 +78,16 @@
return render_to_response('teams/team_list.html', context,
RequestContext(request))
+def team_ical(request, team_slug):
+ """
+ Return a ical list with the events and meetings in ical format.
+ """
+ team_object = get_object_or_404(Team, lp_name=team_slug)
+ team_events = list(TeamEvent.objects.filter(teams__lp_name=team_slug))
+ team_meetings = list(TeamMeeting.objects.filter(teams__lp_name=team_slug))
+ team_events.extend(team_meetings)
+ return as_ical(team_events, team_object.name)
+
def team_event_list(request, team_slug):
"""
list with all team events in present and future for the given team
=== modified file 'loco_directory/templates/teams/team_detail.html'
--- loco_directory/templates/teams/team_detail.html 2011-02-17 19:30:47 +0000
+++ loco_directory/templates/teams/team_detail.html 2011-02-17 21:20:16 +0000
@@ -184,7 +184,7 @@
<li style="font-size:0.98em"><a href="{% url team-meeting-list team.lp_name %}">{% trans "All Meetings" %}</a></li>
<li style="font-size:0.98em"><a href="{% url team-event-history team.lp_name %}">{% trans "Past Events" %}</a></li>
<li style="font-size:0.98em"><a href="{% url team-events-rss team.lp_name %}">{% trans "RSS Feed" %}</a></li>
- <li style="font-size:0.98em"><a href="{% url team-event-list-ical team.lp_name %}">{% trans "iCal Feed" %}</a></li>
+ <li style="font-size:0.98em"><a href="{% url team-calendar team.lp_name %}">{% trans "iCal Feed" %}</a></li>
</ul>
{% if team.next_5_events_and_meetings %}
<ul>
_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help : https://help.launchpad.net/ListHelp