summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/meetingtools/ac/__init__.py12
-rw-r--r--src/meetingtools/apps/auth/views.py4
-rw-r--r--src/meetingtools/apps/cluster/models.py14
-rw-r--r--src/meetingtools/apps/room/views.py16
4 files changed, 26 insertions, 20 deletions
diff --git a/src/meetingtools/ac/__init__.py b/src/meetingtools/ac/__init__.py
index b138237..9e47430 100644
--- a/src/meetingtools/ac/__init__.py
+++ b/src/meetingtools/ac/__init__.py
@@ -1,21 +1,25 @@
from meetingtools.ac.api import ACPClient
import time
+from meetingtools.apps.cluster.models import acc_for_user
-def ac_api_client_cache(request,acc):
+def ac_api_client_cache(request,acc=None):
+ if acc == None:
+ acc = acc_for_user(request.user)
tag = 'ac_api_client_%s' % acc.name
if not request.session.has_key(tag):
request.session[tag] = ACPClientWrapper(acc)
return request.session[tag]
-def ac_api_client_nocache(request,acc):
+def ac_api_client_nocache(request,acc=None):
+ if acc == None:
+ acc = acc_for_user(request.user)
return ACPClientWrapper(acc)
ac_api_client = ac_api_client_cache
-def ac_api(request,acc):
+def ac_api(request,acc=None):
return ACPClient(acc.api_url,acc.user,acc.password)
-
MAXCALLS = 10
MAXIDLE = 10
diff --git a/src/meetingtools/apps/auth/views.py b/src/meetingtools/apps/auth/views.py
index a412ed5..c0adfc2 100644
--- a/src/meetingtools/apps/auth/views.py
+++ b/src/meetingtools/apps/auth/views.py
@@ -10,12 +10,12 @@ from django.views.decorators.cache import never_cache
import logging
from meetingtools.apps.userprofile.models import UserProfile
from meetingtools.multiresponse import redirect_to, make_response_dict
-from meetingtools.apps.room.views import _acc_for_user
from meetingtools.ac import ac_api_client, ac_api
from django.shortcuts import render_to_response
from django.contrib import auth
from django_co_connector.models import co_import_from_request, add_member,\
remove_member
+from meetingtools.apps.cluster.models import acc_for_user
def meta(request,attr):
v = request.META.get(attr)
@@ -58,7 +58,7 @@ def login(request):
def join_group(group,**kwargs):
user = kwargs['user']
- acc = _acc_for_user(user)
+ acc = acc_for_user(user)
connect_api = ac_api(acc)
principal = connect_api.find_principal("login", user.username, "user")
if principal:
diff --git a/src/meetingtools/apps/cluster/models.py b/src/meetingtools/apps/cluster/models.py
index 13b4aae..7b59771 100644
--- a/src/meetingtools/apps/cluster/models.py
+++ b/src/meetingtools/apps/cluster/models.py
@@ -6,6 +6,7 @@ Created on Feb 3, 2011
from django.db import models
from django.db.models.fields import CharField, URLField, TextField, IntegerField
+import re
class ACCluster(models.Model):
api_url = URLField()
@@ -20,4 +21,15 @@ class ACCluster(models.Model):
return self.url
def make_url(self,path=""):
- return "%s%s" % (self.url,path) \ No newline at end of file
+ return "%s%s" % (self.url,path)
+
+def acc_for_user(user):
+ (local,domain) = user.username.split('@')
+ if not domain:
+ #raise Exception,"Improperly formatted user: %s" % user.username
+ domain = "nordu.net" # testing with local accts only
+ for acc in ACCluster.objects.all():
+ for regex in acc.domain_match.split():
+ if re.match(regex,domain):
+ return acc
+ raise Exception,"I don't know which cluster you belong to... (%s)" % user.username \ No newline at end of file
diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py
index b2c3e13..0eae2f6 100644
--- a/src/meetingtools/apps/room/views.py
+++ b/src/meetingtools/apps/room/views.py
@@ -28,17 +28,7 @@ from tagging.models import Tag, TaggedItem
import random, string
from django.utils.feedgenerator import rfc3339_date
from django.views.decorators.cache import cache_control, never_cache
-
-def _acc_for_user(user):
- (local,domain) = user.username.split('@')
- if not domain:
- #raise Exception,"Improperly formatted user: %s" % user.username
- domain = "nordu.net" # testing with local accts only
- for acc in ACCluster.objects.all():
- for regex in acc.domain_match.split():
- if re.match(regex,domain):
- return acc
- raise Exception,"I don't know which cluster you belong to... (%s)" % user.username
+from meetingtools.apps.cluster.models import acc_for_user
def _user_meeting_folder(request,acc):
if not session(request,'my_meetings_sco_id'):
@@ -191,7 +181,7 @@ def _update_room(request, room, form=None):
@never_cache
@login_required
def create(request):
- acc = _acc_for_user(request.user)
+ acc = acc_for_user(request.user)
my_meetings_sco_id = _user_meeting_folder(request,acc)
template_sco_id = acc.default_template_sco_id
if not template_sco_id:
@@ -287,7 +277,7 @@ def _import_room(request,acc,r):
@login_required
def user_rooms(request):
- acc = _acc_for_user(request.user)
+ 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)