diff options
author | Leif Johansson <leifj@sunet.se> | 2011-05-14 00:39:13 +0200 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2011-05-14 00:39:13 +0200 |
commit | 68c5618c30b12e8c5cb6c2d96c4381eb00c95299 (patch) | |
tree | dd13fb8746b0a90001fb7e6e5afeae53ff2eebff /src/meetingtools/apps/room | |
parent | fa14e453d51e3106734323a21d6ee68f30dd99e3 (diff) |
atom and rss feed of recordings of each room
Diffstat (limited to 'src/meetingtools/apps/room')
-rw-r--r-- | src/meetingtools/apps/room/feeds.py | 45 | ||||
-rw-r--r-- | src/meetingtools/apps/room/models.py | 3 | ||||
-rw-r--r-- | src/meetingtools/apps/room/views.py | 22 |
3 files changed, 58 insertions, 12 deletions
diff --git a/src/meetingtools/apps/room/feeds.py b/src/meetingtools/apps/room/feeds.py index 0254339..3dff05e 100644 --- a/src/meetingtools/apps/room/feeds.py +++ b/src/meetingtools/apps/room/feeds.py @@ -9,6 +9,8 @@ from meetingtools.apps.room.models import Room from tagging.models import TaggedItem from meetingtools.settings import BASE_URL from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed +from meetingtools.apps.room.views import room_recordings +from django.shortcuts import get_object_or_404 class TagsWrapper(object): @@ -25,7 +27,7 @@ class TagsWrapper(object): def link(self,ext): return "%s/room/+%s.%s" % (BASE_URL,"+".join(self.tags),ext) -class RoomTagFeed(Feed): +class MeetingToolsFeed(Feed): item_author_name = 'SUNET e-meeting tools' @@ -37,6 +39,9 @@ class RoomTagFeed(Feed): return "rss" return "rss" + + +class RoomTagFeed(MeetingToolsFeed): def get_object(self,request,tn): return TagsWrapper(tn) @@ -73,4 +78,42 @@ class RoomAtomTagFeed(RoomTagFeed): feed_type = Atom1Feed class RoomRSSTagField(RoomTagFeed): + feed_type = Rss201rev2Feed + +class RecordingsWrapper(object): + def __init__(self,room,request): + self.room = room + self.items = room_recordings(request, room) + +class RecordingFeed(MeetingToolsFeed): + + def get_object(self,request,rid): + room = get_object_or_404(Room,pk=rid) + return RecordingsWrapper(room,request) + + def title(self,recordings): + return "Recordings in room '%s'" % recordings.room.name + + def link(self,recordings): + return recordings.room.recordings_url() + + def items(self,recordings): + return recordings.items + + def item_title(self,recording): + return recording['name'] + + def item_description(self,recording): + return recording['description'] + + def item_link(self,recording): + return recording['url'] + + def item_pubdate(self,recording): + return recording['date_created'] + +class AtomRecordingFeed(RecordingFeed): + feed_type = Atom1Feed + +class RSSRecordingField(RecordingFeed): feed_type = Rss201rev2Feed
\ No newline at end of file diff --git a/src/meetingtools/apps/room/models.py b/src/meetingtools/apps/room/models.py index a54f1e9..b49925a 100644 --- a/src/meetingtools/apps/room/models.py +++ b/src/meetingtools/apps/room/models.py @@ -51,6 +51,9 @@ class Room(models.Model): def permalink(self): return "%s/room/%d" % (BASE_URL,self.id) + + def recordings_url(self): + return "%s/room/%d/recordings" % (BASE_URL,self.id) def nusers(self): if self.user_count == None: diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py index b0297cd..6df49fe 100644 --- a/src/meetingtools/apps/room/views.py +++ b/src/meetingtools/apps/room/views.py @@ -448,19 +448,19 @@ def tag(request,rid): from time import mktime from feedparser import _parse_date as parse_date +def room_recordings(request,room): + api = ac_api_client(request, room.acc) + r = api.request('sco-expanded-contents',{'sco-id': room.sco_id,'filter-icon':'archive'},True) + return [{'name': sco.findtext('name'), + 'sco_id': sco.get('sco-id'), + 'url': room.acc.make_url(sco.findtext('url-path')), + 'description': sco.findtext('description'), + 'date_created': datetime.fromtimestamp(mktime(parse_date(sco.findtext('date-created')))), + 'date_modified': datetime.fromtimestamp(mktime(parse_date(sco.findtext('date-modified'))))} for sco in r.et.findall(".//sco")] + @login_required def recordings(request,rid): room = get_object_or_404(Room,pk=rid) - api = ac_api_client(request, room.acc) - - r = api.request('sco-expanded-contents',{'sco-id': room.sco_id,'filter-icon':'archive'},True) - recordings = [{'name': sco.findtext('name'), - 'sco_id': sco.get('sco-id'), - 'url': room.acc.make_url(sco.findtext('url-path')), - 'description': sco.findtext('description'), - 'date_created': datetime.fromtimestamp(mktime(parse_date(sco.findtext('date-created')))), - 'date_modified': datetime.fromtimestamp(mktime(parse_date(sco.findtext('date-modified'))))} for sco in r.et.findall(".//sco")] - return respond_to(request, {'text/html': 'apps/room/recordings.html'}, - {'recordings': recordings,'room':room})
\ No newline at end of file + {'recordings': room_recordings(request,room),'room':room})
\ No newline at end of file |