diff options
author | Leif Johansson <leifj@sunet.se> | 2012-11-01 01:25:23 +0100 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2012-11-01 01:25:23 +0100 |
commit | f131d65477d055c5a50cadd719c2c46d69e00289 (patch) | |
tree | 2f8e267c2e8b52fc44b19a780ae47e8b8216b6a0 /meetingtools/apps | |
parent | 7e899faf1b3e558e3f6cbb690a84d5ba21ae8661 (diff) |
handle the non-uniqueness of room urlpaths
Diffstat (limited to 'meetingtools/apps')
-rw-r--r-- | meetingtools/apps/room/views.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/meetingtools/apps/room/views.py b/meetingtools/apps/room/views.py index c19a242..3476af8 100644 --- a/meetingtools/apps/room/views.py +++ b/meetingtools/apps/room/views.py @@ -19,7 +19,7 @@ from meetingtools.utils import session, base_url import time from django.conf import settings from django.utils.datetime_safe import datetime -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, HttpResponseNotFound from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django_co_acls.models import allow, acl, clear_acl from meetingtools.ac.api import ACPClient @@ -380,8 +380,17 @@ def go_by_id(request,id): return goto(request,room) def go_by_path(request,path): - room = get_object_or_404(Room,urlpath=path) - return goto(request,room) + rooms = Room.objects.filter(urlpath=path) + if len(rooms) == 1: + return goto(request,rooms[0]) + + if len(rooms) == 0: + return HttpResponseNotFound() + + return respond_to(request, + {'text/html': 'apps/room/choose.html', + 'application/json': json_response([base_url(request,room.go_url()) for room in rooms])}, + {'rooms': rooms}) @login_required def promote_and_launch(request,rid): |