summaryrefslogtreecommitdiff
path: root/src/meetingtools
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-05-12 09:31:47 +0200
committerLeif Johansson <leifj@sunet.se>2011-05-12 09:31:47 +0200
commit323a8afc95fafcf3609685212fe46efa43b11825 (patch)
tree34728ab4ec69345b2717f994e35da21358c8d58f /src/meetingtools
parente1924fce1729b610f55f9afe85d7ccfd81d569ef (diff)
json version
Diffstat (limited to 'src/meetingtools')
-rw-r--r--src/meetingtools/apps/room/views.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py
index ec164f0..698d755 100644
--- a/src/meetingtools/apps/room/views.py
+++ b/src/meetingtools/apps/room/views.py
@@ -4,7 +4,7 @@ Created on Jan 31, 2011
@author: leifj
'''
from meetingtools.apps.room.models import Room, ACCluster
-from meetingtools.multiresponse import respond_to, redirect_to
+from meetingtools.multiresponse import respond_to, redirect_to, json_response
from meetingtools.apps.room.forms import DeleteRoomForm,\
CreateRoomForm, ModifyRoomForm, TagRoomForm
from django.shortcuts import get_object_or_404
@@ -376,12 +376,36 @@ def _goto(request,room,clean=True,promote=False):
## Tagging
+def _room2dict(room):
+ return {'name':room.name,
+ 'description':room.description,
+ 'user_count':room.user_count,
+ 'self_cleaning': room.self_cleaning,
+ 'url': room.go_url()}
+
+@login_required
+def widget(request,tn):
+ tags = tn.split('+')
+ rooms = TaggedItem.objects.get_by_model(Room, tags)
+ title = 'Rooms tagged with %s' % " and ".join(tags)
+ return respond_to(request,
+ {'text/html':'apps/room/widget-test.html',
+ 'application/json': json_response([_room2dict(room) for room in rooms]),
+ 'application/rss+xml': 'apps/room/rss2.xml',
+ 'text/rss': 'apps/room/rss2.xml'},
+ {'title':title,'description':title ,'edit':False,'date': datetime.now(),'tags': tn,'rooms':rooms.all()})
+
@login_required
def list_by_tag(request,tn):
tags = tn.split('+')
rooms = TaggedItem.objects.get_by_model(Room, tags)
-
- return respond_to(request,{'text/html':'apps/room/list.html'},{'title':'Rooms tagged with %s' % " and ".join(tags),'edit':False,'rooms':rooms.all()})
+ title = 'Rooms tagged with %s' % " and ".join(tags)
+ return respond_to(request,
+ {'text/html':'apps/room/list.html',
+ 'application/json': json_response([_room2dict(room) for room in rooms]),
+ 'application/rss+xml': 'apps/room/rss2.xml',
+ 'text/rss': 'apps/room/rss2.xml'},
+ {'title':title,'description':title ,'edit':False,'date': datetime.now(),'tags': tn,'rooms':rooms.all()})
def _can_tag(request,tag):
if tag in ('selfcleaning','public','private'):