diff options
Diffstat (limited to 'src/meetingtools')
-rw-r--r-- | src/meetingtools/apps/auth/views.py | 3 | ||||
-rw-r--r-- | src/meetingtools/apps/room/forms.py | 7 | ||||
-rw-r--r-- | src/meetingtools/apps/room/models.py | 6 | ||||
-rw-r--r-- | src/meetingtools/apps/room/views.py | 46 | ||||
-rw-r--r-- | src/meetingtools/settings.py | 1 | ||||
-rw-r--r-- | src/meetingtools/urls.py | 7 |
6 files changed, 60 insertions, 10 deletions
diff --git a/src/meetingtools/apps/auth/views.py b/src/meetingtools/apps/auth/views.py index 0c46338..8b0a8fd 100644 --- a/src/meetingtools/apps/auth/views.py +++ b/src/meetingtools/apps/auth/views.py @@ -141,10 +141,11 @@ def accounts_login_federated(request): 'last-name':ln, 'email':mail, 'send-email': 0, - 'password': key, 'login':request.user.username, 'ext-login':request.user.username}) + connect_api.request("user-update-pwd",{"user-id": principal.get('principal-id'),'password': key,'password-verify': key},True) + co_import_from_request(request) member_or_employee = _is_member_or_employee(request.user) diff --git a/src/meetingtools/apps/room/forms.py b/src/meetingtools/apps/room/forms.py index 143551a..ed4287f 100644 --- a/src/meetingtools/apps/room/forms.py +++ b/src/meetingtools/apps/room/forms.py @@ -6,7 +6,7 @@ Created on Feb 1, 2011 from meetingtools.apps.room.models import Room from django.forms.widgets import Select, TextInput, RadioSelect -from django.forms.fields import BooleanField, ChoiceField +from django.forms.fields import BooleanField, ChoiceField, CharField from django.forms.forms import Form from form_utils.forms import BetterModelForm from django.utils.safestring import mark_safe @@ -81,4 +81,7 @@ class CreateRoomForm(BetterModelForm): 'name': TextInput(attrs={'size': '40'})} class DeleteRoomForm(Form): - confirm = BooleanField(label="Confirm remove room")
\ No newline at end of file + confirm = BooleanField(label="Confirm remove room") + +class TagRoomForm(Form): + tag = CharField(max_length=256)
\ No newline at end of file diff --git a/src/meetingtools/apps/room/models.py b/src/meetingtools/apps/room/models.py index 736c63f..a71e608 100644 --- a/src/meetingtools/apps/room/models.py +++ b/src/meetingtools/apps/room/models.py @@ -11,7 +11,7 @@ from django.db.models.fields.related import ForeignKey from django.contrib.auth.models import User from meetingtools.apps.cluster.models import ACCluster import time -from django_co_acls.models import AccessControlEntry +import tagging class Room(models.Model): creator = ForeignKey(User,editable=False) @@ -38,4 +38,6 @@ class Room(models.Model): if not self.lastvisited: return 0 else: - return int(time.mktime(self.lastvisited.timetuple())*1000)
\ No newline at end of file + return int(time.mktime(self.lastvisited.timetuple())*1000) + +tagging.register(Room)
\ No newline at end of file diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py index 81ce1dc..201509e 100644 --- a/src/meetingtools/apps/room/views.py +++ b/src/meetingtools/apps/room/views.py @@ -6,7 +6,7 @@ Created on Jan 31, 2011 from meetingtools.apps.room.models import Room, ACCluster from meetingtools.multiresponse import respond_to, redirect_to from meetingtools.apps.room.forms import DeleteRoomForm,\ - CreateRoomForm, ModifyRoomForm + CreateRoomForm, ModifyRoomForm, TagRoomForm from django.shortcuts import get_object_or_404 from meetingtools.ac import ac_api_client, api import re @@ -22,6 +22,7 @@ from django.http import HttpResponseRedirect 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 def _acc_for_user(user): (local,domain) = user.username.split('@') @@ -348,4 +349,45 @@ def goto(request,room): return user_client.redirect_to(room.acc.url+urlpath) else: return HttpResponseRedirect(room.acc.url+urlpath) -
\ No newline at end of file + +## Tagging + +@login_required +def list_by_tag(request,tn): + tags = tn.split('+') + rooms = TaggedItem.objects.get_by_model(Room, tags) + + +def _can_tag(request,tag): + if tag in ('selfcleaning','public','private'): + return False,"'%s' is reserved" % tag + # XXX implement access model for tags here soon + return True,"" + +@login_required +def untag(request,rid,tag): + room = get_object_or_404(Room,pk=rid) + new_tags = [] + for t in Tag.objects.get_for_object(room): + if t.name != tag: + new_tags.append(t.name) + + Tag.objects.update_tags(room, ' '.join(new_tags)) + return redirect_to("/room/%d/tag" % room.id) + +@login_required +def tag(request,rid): + room = get_object_or_404(Room,pk=rid) + if request.method == 'POST': + form = TagRoomForm(request.POST) + if form.is_valid(): + tag = form.cleaned_data['tag'] + ok,reason = _can_tag(request,tag) + if ok: + Tag.objects.add_tag(room, tag) + else: + form._errors['tag'] = form.error_class([u'%s ... please choose another tag!' % reason]) + 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 diff --git a/src/meetingtools/settings.py b/src/meetingtools/settings.py index 34a4c06..a09da72 100644 --- a/src/meetingtools/settings.py +++ b/src/meetingtools/settings.py @@ -106,6 +106,7 @@ INSTALLED_APPS = ( 'django_extensions', 'django_co_connector', 'django_co_acls', + 'tagging', 'meetingtools.extensions', 'meetingtools.apps.auth', 'meetingtools.apps.room', diff --git a/src/meetingtools/urls.py b/src/meetingtools/urls.py index 568ac83..27980f2 100644 --- a/src/meetingtools/urls.py +++ b/src/meetingtools/urls.py @@ -1,9 +1,7 @@ -from django.conf.urls.defaults import * +from django.conf.urls.defaults import patterns,include # Uncomment the next two lines to enable the admin: from django.contrib import admin -from django.http import HttpResponseRedirect -from django.contrib.auth.views import login, logout from meetingtools.settings import ADMIN_MEDIA_ROOT, MEDIA_ROOT from meetingtools.multiresponse import redirect_to admin.autodiscover() @@ -27,6 +25,9 @@ urlpatterns = patterns('', (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'), # Uncomment the admin/doc line below to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), |