summaryrefslogtreecommitdiff
path: root/src/meetingtools/apps/cluster
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2012-01-17 10:51:46 +0100
committerLeif Johansson <leifj@sunet.se>2012-01-17 10:51:46 +0100
commit156b905ef6c63647f9ce163a3b0f2c5b9e00ea41 (patch)
tree8ed0fb2a6be0aaf2500d46dea5bd6e3547337d48 /src/meetingtools/apps/cluster
parent4b5f7d87df4b59ea8d215ae4a64e68ff73e1dd16 (diff)
move acc_for_user to cluster model as a generic method
Diffstat (limited to 'src/meetingtools/apps/cluster')
-rw-r--r--src/meetingtools/apps/cluster/models.py14
1 files changed, 13 insertions, 1 deletions
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