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 | |
parent | 7e899faf1b3e558e3f6cbb690a84d5ba21ae8661 (diff) |
handle the non-uniqueness of room urlpaths
-rw-r--r-- | meetingtools/apps/room/views.py | 15 | ||||
-rw-r--r-- | templates/apps/room/choose.html | 15 |
2 files changed, 27 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): diff --git a/templates/apps/room/choose.html b/templates/apps/room/choose.html new file mode 100644 index 0000000..c933b5a --- /dev/null +++ b/templates/apps/room/choose.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% block content %} +<div class="page-header"> + <h1>Choose which room to visit</h1> +</div> +<div class="alert"> + <i class="icon-info-sign"> </i> + Multiple rooms match your search. Please select which one to visit from the list below: +</div> + <ul class="unstyled"> + {% for room in rooms %} + <li><a href="{{BASE_URL}}go/{{room.id}}">{{room}} hosted on {{room.sco.acc.name}}</a></li> + {% endfor %} + </ul> +{% endblock %}
\ No newline at end of file |