From f131d65477d055c5a50cadd719c2c46d69e00289 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Thu, 1 Nov 2012 01:25:23 +0100 Subject: handle the non-uniqueness of room urlpaths --- meetingtools/apps/room/views.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'meetingtools/apps/room') 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): -- cgit v1.1