summaryrefslogtreecommitdiff
path: root/meetingtools/apps/cluster/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'meetingtools/apps/cluster/models.py')
-rw-r--r--meetingtools/apps/cluster/models.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/meetingtools/apps/cluster/models.py b/meetingtools/apps/cluster/models.py
new file mode 100644
index 0000000..3c65d57
--- /dev/null
+++ b/meetingtools/apps/cluster/models.py
@@ -0,0 +1,35 @@
+'''
+Created on Feb 3, 2011
+
+@author: leifj
+'''
+
+from django.db import models
+from django.db.models.fields import CharField, URLField, TextField, IntegerField
+import re
+
+class ACCluster(models.Model):
+ api_url = URLField()
+ url = URLField()
+ user = CharField(max_length=128)
+ password = CharField(max_length=128)
+ name = CharField(max_length=128,blank=True,unique=True)
+ default_template_sco_id = IntegerField(blank=True,unique=True)
+ domain_match = TextField()
+
+ def __unicode__(self):
+ return self.url
+
+ def make_url(self,path=""):
+ 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.strip(),domain):
+ return acc
+ raise Exception,"I don't know which cluster you belong to... (%s)" % user.username