From 0d218d69284497581c869ecc1606cfd173e87745 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Fri, 26 Oct 2012 17:13:17 +0200 Subject: return absolute URLs in json metadata --- meetingtools/apps/room/views.py | 6 +++--- meetingtools/utils.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'meetingtools') diff --git a/meetingtools/apps/room/views.py b/meetingtools/apps/room/views.py index 9d0292d..92c9f8d 100644 --- a/meetingtools/apps/room/views.py +++ b/meetingtools/apps/room/views.py @@ -449,14 +449,14 @@ def _goto(request,room,clean=True,promote=False): ## Tagging -def _room2dict(room): +def _room2dict(request,room): return {'name':room.name, 'description':room.description, 'user_count':room.nusers(), 'host_count':room.nhosts(), 'updated': rfc3339_date(room.lastupdated), 'self_cleaning': room.self_cleaning, - 'url': room.go_url()} + 'url': base_url(request,room.go_url())} # should not require login def list_by_tag(request,tn): @@ -465,7 +465,7 @@ def list_by_tag(request,tn): 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],request)}, + 'application/json': json_response([_room2dict(request,room) for room in rooms],request)}, {'title':title, 'description':title , 'edit':False, diff --git a/meetingtools/utils.py b/meetingtools/utils.py index eee0d80..767da43 100644 --- a/meetingtools/utils.py +++ b/meetingtools/utils.py @@ -16,5 +16,5 @@ def session(request,key=None,val=None): else: return request.session -def base_url(request): - return "%s://%s/" % ({True: 'https',False:'http'}[request.is_secure()],request.get_host()) \ No newline at end of file +def base_url(request,path="/"): + return "%s://%s%s" % ({True: 'https',False:'http'}[request.is_secure()],request.get_host(),path) \ No newline at end of file -- cgit v1.1