summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/meetingtools/apps/room/views.py69
-rw-r--r--src/meetingtools/urls.py7
-rw-r--r--src/templates/apps/room/list.html33
-rw-r--r--src/templates/apps/room/tag.html36
4 files changed, 87 insertions, 58 deletions
diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py
index c77f81d..ec164f0 100644
--- a/src/meetingtools/apps/room/views.py
+++ b/src/meetingtools/apps/room/views.py
@@ -23,6 +23,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django_co_acls.models import allow, deny, acl, clear_acl
from meetingtools.ac.api import ACPClient
from tagging.models import Tag, TaggedItem
+import random, string
def _acc_for_user(user):
(local,domain) = user.username.split('@')
@@ -205,7 +206,7 @@ def create(request):
form = CreateRoomForm(instance=room)
_init_update_form(request, form, acc, room.folder_sco_id)
- return respond_to(request,{'text/html':'apps/room/create.html'},{'form':form,'formtitle': title,'submitname':'%s Room' % what})
+ return respond_to(request,{'text/html':'apps/room/create.html'},{'form':form,'formtitle': title,'cancelname':'Cancel','submitname':'%s Room' % what})
@login_required
def update(request,id):
@@ -225,7 +226,7 @@ def update(request,id):
form = ModifyRoomForm(instance=room)
_init_update_form(request, form, acc, room.folder_sco_id)
- return respond_to(request,{'text/html':'apps/room/update.html'},{'form':form,'formtitle': title,'submitname':'%s Room' % what})
+ return respond_to(request,{'text/html':'apps/room/update.html'},{'form':form,'formtitle': title,'cancelname': 'Cancel','submitname':'%s Room' % what})
def _import_room(request,acc,sco_id,source_sco_id,folder_sco_id,name,urlpath,description=None):
modified = False
@@ -272,7 +273,7 @@ def _import_room(request,acc,sco_id,source_sco_id,folder_sco_id,name,urlpath,des
return room
@login_required
-def list(request):
+def user_rooms(request):
acc = _acc_for_user(request.user)
my_meetings_sco_id = _user_meeting_folder(request,acc)
user_rooms = _user_rooms(request,acc,my_meetings_sco_id)
@@ -282,19 +283,14 @@ def list(request):
ar.append(int(sco_id))
for r in Room.objects.filter(creator=request.user).all():
- #logging.debug(pformat(r))
if (not r.sco_id in ar): # and (not r.self_cleaning): #XXX this logic isn't right!
r.delete()
for (sco_id,name,source_sco_id,urlpath,description) in user_rooms:
logging.debug("%s %s %s %s" % (sco_id,name,source_sco_id,urlpath))
room = _import_room(request,acc,sco_id,source_sco_id,my_meetings_sco_id,name,urlpath,description)
-
- return respond_to(request,{'text/html':'apps/room/list.html'},{'user':request.user,'rooms':Room.objects.filter(creator=request.user).all()})
-
-def rooms_by_group(request,group):
- for room in Room.objects.filter(participants=group):
- pass
+
+ return respond_to(request,{'text/html':'apps/room/list.html'},{'title':'Your Rooms','edit':True,'rooms':Room.objects.filter(creator=request.user).all()})
@login_required
def delete(request,id):
@@ -311,7 +307,7 @@ def delete(request,id):
else:
form = DeleteRoomForm()
- return respond_to(request,{'text/html':'edit.html'},{'form':form,'formtitle': 'Delete %s' % room.name,'submitname':'Delete Room'})
+ return respond_to(request,{'text/html':'edit.html'},{'form':form,'formtitle': 'Delete %s' % room.name,'cancelname':'Cancel','submitname':'Delete Room'})
def _clean(request,room):
api = ac_api_client(request, room.acc)
@@ -327,21 +323,51 @@ def go_by_path(request,path):
room = get_object_or_404(Room,urlpath=path)
return goto(request,room)
+@login_required
+def promote_and_launch(request,rid):
+ room = get_object_or_404(Room,pk=rid)
+ return _goto(request,room,clean=False,promote=True)
+
+def launch(request,rid):
+ room = get_object_or_404(Room,pk=rid)
+ return _goto(request,room,clean=False)
+
def goto(request,room):
+ return _goto(request,room,clean=True)
+
+def _random_key(length=20):
+ rg = random.SystemRandom()
+ alphabet = string.letters + string.digits
+ return str().join(rg.choice(alphabet) for _ in range(length))
+
+def _goto(request,room,clean=True,promote=False):
api = ac_api_client(request, room.acc)
- session_info = api.request('report-meeting-sessions',{'sco-id':room.sco_id})
now = time.time()
- room.user_count = _nusers(session_info)
- if room.self_cleaning:
- if (room.user_count == 0) and (abs(room.lastvisit() - now) > GRACE):
- room = _clean(request,room)
-
room.lastvisited = datetime.now()
- room.save()
- r = api.request('sco-info',{'sco-id':room.sco_id})
+ if clean:
+ session_info = api.request('report-meeting-sessions',{'sco-id':room.sco_id})
+ room.user_count = _nusers(session_info)
+ room.save()
+ if room.self_cleaning:
+ if (room.user_count == 0) and (abs(room.lastvisit() - now) > GRACE):
+ room = _clean(request,room)
+ return respond_to(request, {"text/html": "apps/room/launch.html"}, {'room': room})
+ else:
+ room.save()
+
+ key = None
+ if request.user.is_authenticated():
+ key = _random_key(20)
+ user_principal = api.find_user(request.user.username)
+ principal_id = user_principal.get('principal-id')
+ api.request("user-update-pwd",{"user-id": principal_id, 'password': key,'password-verify': key},True)
+ if promote and room.self_cleaning:
+ if user_principal:
+ api.request('permissions-update',{'acl-id': room.sco_id,'principal-id': user_principal.get('principal-id'),'permission-id':'host'},True)
+
+ r = api.request('sco-info',{'sco-id':room.sco_id},True)
urlpath = r.et.findtext('.//sco/url-path')
- key = request.session.get('ac_key',None)
if key:
user_client = ACPClient(room.acc.api_url, request.user.username, key, cache=False)
return user_client.redirect_to(room.acc.url+urlpath)
@@ -355,6 +381,7 @@ 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()})
def _can_tag(request,tag):
if tag in ('selfcleaning','public','private'):
@@ -388,4 +415,4 @@ def tag(request,rid):
else:
form = TagRoomForm()
- return respond_to(request, {'text/html': "apps/room/tag.html"}, {'form': form,'formtitle': 'Add Tag','submitname': 'Add Tag','room': room, 'tags': Tag.objects.get_for_object(room)}) \ No newline at end of file
+ return respond_to(request, {'text/html': "apps/room/tag.html"}, {'form': form,'formtitle': 'Add Tag','cancelname':'Done','submitname': 'Add Tag','room': room, 'tags': Tag.objects.get_for_object(room)}) \ No newline at end of file
diff --git a/src/meetingtools/urls.py b/src/meetingtools/urls.py
index 27980f2..7fc5f6e 100644
--- a/src/meetingtools/urls.py
+++ b/src/meetingtools/urls.py
@@ -17,17 +17,18 @@ urlpatterns = patterns('',
(r'^accounts/login/?$','meetingtools.apps.auth.views.login'),
(r'^accounts/login-federated/$','meetingtools.apps.auth.views.accounts_login_federated'),
(r'^accounts/logout/$','meetingtools.apps.auth.views.logout'),
- (r'^rooms?$','meetingtools.apps.room.views.list'),
- (r'^rooms/(.+)(?:\.([^\.]+))?$','meetingtools.apps.room.views.rooms_by_group'),
+ (r'^rooms?$','meetingtools.apps.room.views.user_rooms'),
(r'^go/(\d+)$','meetingtools.apps.room.views.go_by_id'),
(r'^go/(.+)$','meetingtools.apps.room.views.go_by_path'),
+ (r'^launch/(\d+)$','meetingtools.apps.room.views.launch'),
+ (r'^promote/(\d+)$','meetingtools.apps.room.views.promote_and_launch'),
(r'^room/create$','meetingtools.apps.room.views.create'),
(r'^room/(\d+)$','meetingtools.apps.room.views.view'),
(r'^room/(\d+)/modify$','meetingtools.apps.room.views.update'),
(r'^room/(\d+)/delete$','meetingtools.apps.room.views.delete'),
(r'^room/(\d+)/tag$','meetingtools.apps.room.views.tag'),
(r'^room/(\d+)/untag/(.+)$','meetingtools.apps.room.views.untag'),
- (r'^\+(.+)','meetingtools.apps.room.views.list_by_tag'),
+ (r'^room/\+(.+)','meetingtools.apps.room.views.list_by_tag'),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
diff --git a/src/templates/apps/room/list.html b/src/templates/apps/room/list.html
index 6423296..a8c8954 100644
--- a/src/templates/apps/room/list.html
+++ b/src/templates/apps/room/list.html
@@ -16,7 +16,7 @@
});
{% endblock %}
{% block content %}
- <h1>Your meeting rooms</h1>
+ <h1>{{title}}</h1>
{% if rooms %}
<div id="rooms">
{% for r in rooms %}
@@ -25,32 +25,31 @@
<div>
<ul class="ilist">
<li style="vertical-align: top;">
- <ul class="nlist">
- {% if r.self_cleaning %}<li>Room will be reset when empty.</li>{% endif %}
+ <ul class="nlist square" style="margin-top: 5px;">
<li>Created by {{r.creator}} {{r.timecreated|datehumanize}}.</li>
- {% if r.lastvisited %}<li>Last visited {{r.lastvisited|datehumanize}} when there was {{r.nusers}} user{{r.nusers|pluralize}} in the room.</li>{%endif%}
+ {% if r.self_cleaning %}<li>Room will be reset when empty.</li>{%else%}<li>Room state is preserved between sessions.</li>{% endif %}
+ {% if r.lastvisited %}<li>Last visited {{r.lastvisited|datehumanize}}</li>{%endif%}
<li>Meeting room URL: <a href="{{r|roomurl}}">{{r|roomurl}}<span style="vertical-align: bottom;" class="ui-icon ui-icon-extlink"></span></a></li>
+ <li>Hosted on {{r.acc.name}}</li>
</ul>
</li>
{% tags_for_object r as tags %}
- <li style="vertical-align: top;">
+ <li style="vertical-align: top; width: 45%;">
<ul class="nlist">
- <li>Room tags:
- {% for tag in tags %}
- <a href="{% prefix %}/+{{tag}}">{{tag}}</a>
- {% endfor %} ... <a href="{% prefix %}/room/{{r.id}}/tag"><em>manage room tags</em></a></li>
+ <li style="margin-top: 5px;" class="infopanel ui-widget ui-corner-all ui-state-highlight"><strong>{{r.name}}</strong><p>{% if r.description %}{{r.description|safe}}{% else %}<em>No description available...</em>{% endif %}</p></li>
+ <li style="margin-top: 5px;">Tags: {% for tag in tags %}<a style="margin-right: 5px;" class="ui-widget" href="{% prefix %}/room/+{{tag}}">{{tag}}</a>{% endfor %} {%if edit %}<a style="font-size: 75%;" href="{% prefix %}/room/{{r.id}}/tag"><em>... manage room tags</em></a>{%endif%}</li>
</ul>
</li>
</ul>
<br/>
- {% if r.description %}
- <p class="ui-widget">{{r.description|safe}}</p>
- {% endif %}
<ul class="ilist">
- <!-- li><div class="button"><a href="{% prefix %}/room/{{r.id}}/modify">Modify Room</a></li -->
- <li><div class="button"><a href="{% prefix %}/room/{{r.id}}/delete">Delete Room</a></li>
- <li><div class="button"><a href="{% prefix %}/room/{{r.id}}/tag">Room Tags</a></li>
+ <li class="button"><a href="{% prefix %}/go/{{r.id}}">Enter Room</a></li>
+ {% if edit %}
+ <li class="button"><a href="{% prefix %}/room/{{r.id}}/tag">Room Tags</a></li>
+ <li class="button"><a href="{% prefix %}/room/{{r.id}}/modify">Modify Room</a></li>
+ <li class="button"><a href="{% prefix %}/room/{{r.id}}/delete">Delete Room</a></li>
+ {% endif %}
</ul>
</div>
</div>
@@ -60,7 +59,9 @@
<p>You don't have any rooms listed right now...</p>
{% endif %}
<br/>
+ {% if edit %}
<ul class="ilist">
- <li><div class="button"><a href="{% prefix %}/room/create">Create a new room</a></div></li>
+ <li><div class="button"><a href="{% prefix %}/room/create">Create a New Room</a></div></li>
</ul>
+ {% endif %}
{% endblock %} \ No newline at end of file
diff --git a/src/templates/apps/room/tag.html b/src/templates/apps/room/tag.html
index 7e0a93b..2a19304 100644
--- a/src/templates/apps/room/tag.html
+++ b/src/templates/apps/room/tag.html
@@ -8,25 +8,25 @@
{% endblock %}
{% block beforefields %}
<div class="ui-widget">
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
- <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
- <strong>Note Well</strong> Tags are a way to group related rooms together. Tagging your
- room makes your room show up in public lists of rooms hosted on this service and it
- therefore makes your room more visible.</p>
- </div>
+ <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
+ <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
+ <strong>Note Well</strong> Tags are a way to group related rooms together. Tagging your
+ room makes your room show up in public lists of rooms hosted on this service and it
+ therefore makes your room more visible.</p>
</div>
- <br/>
+</div>
+<br/>
{% endblock %}
{% block beforeform %}
- <h1>Current tags for {{room.name}}</h1>
- {% if tags %}
- <ul class="ilist">
- {% for tag in tags %}
- <li class="ui-widget ui-state-highlight ui-corner-all" style="padding: 6px 10px;"><a href="{%prefix%}/+{{tag}}">{{tag}}</a>&nbsp;<a href="{% prefix %}/room/{{room.id}}/untag/{{tag}}"><span style="vertical-align: middle;" class="ui-icon ui-icon-closethick"></span></a></li>
- {% endfor %}
- </ul>
- {% else %}
- <em>There are no tags yet...</em>
- {% endif %}
- <br/>
+<h1>Current tags for {{room.name}}</h1>
+{% if tags %}
+<ul class="ilist">
+ {% for tag in tags %}
+ <li class="ui-widget ui-state-highlight ui-corner-all" style="padding: 6px 10px;"><a href="{%prefix%}/room/+{{tag}}">{{tag}}</a>&nbsp;<a href="{% prefix %}/room/{{room.id}}/untag/{{tag}}"><span style="vertical-align: middle;" class="ui-icon ui-icon-closethick"></span></a></li>
+ {% endfor %}
+</ul>
+{% else %}
+<em>There are no tags yet...</em>
+{% endif %}
+<br/>
{% endblock %} \ No newline at end of file