summaryrefslogtreecommitdiff
path: root/meetingtools/apps/cluster
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2012-10-04 15:39:08 +0200
committerLeif Johansson <leifj@sunet.se>2012-10-04 15:39:08 +0200
commit2bdad0ae7a3a6e4ec5116becd39910388b679ed2 (patch)
tree5afdfba0a93c1af50d53bdc245d57cc4053e109a /meetingtools/apps/cluster
parent873e7823970352d591deee5f67f47c5436ee0e84 (diff)
restructure
Diffstat (limited to 'meetingtools/apps/cluster')
-rw-r--r--meetingtools/apps/cluster/__init__.py0
-rw-r--r--meetingtools/apps/cluster/admin.py10
-rw-r--r--meetingtools/apps/cluster/migrations/0001_initial.py45
-rw-r--r--meetingtools/apps/cluster/migrations/__init__.py0
-rw-r--r--meetingtools/apps/cluster/models.py35
5 files changed, 90 insertions, 0 deletions
diff --git a/meetingtools/apps/cluster/__init__.py b/meetingtools/apps/cluster/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/meetingtools/apps/cluster/__init__.py
diff --git a/meetingtools/apps/cluster/admin.py b/meetingtools/apps/cluster/admin.py
new file mode 100644
index 0000000..3fc9eea
--- /dev/null
+++ b/meetingtools/apps/cluster/admin.py
@@ -0,0 +1,10 @@
+'''
+Created on Jan 31, 2011
+
+@author: leifj
+'''
+
+from django.contrib import admin
+from meetingtools.apps.cluster.models import ACCluster
+
+admin.site.register(ACCluster) \ No newline at end of file
diff --git a/meetingtools/apps/cluster/migrations/0001_initial.py b/meetingtools/apps/cluster/migrations/0001_initial.py
new file mode 100644
index 0000000..f20f743
--- /dev/null
+++ b/meetingtools/apps/cluster/migrations/0001_initial.py
@@ -0,0 +1,45 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding model 'ACCluster'
+ db.create_table('cluster_accluster', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('api_url', self.gf('django.db.models.fields.URLField')(max_length=200)),
+ ('url', self.gf('django.db.models.fields.URLField')(max_length=200)),
+ ('user', self.gf('django.db.models.fields.CharField')(max_length=128)),
+ ('password', self.gf('django.db.models.fields.CharField')(max_length=128)),
+ ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=128, blank=True)),
+ ('default_template_sco_id', self.gf('django.db.models.fields.IntegerField')(unique=True, blank=True)),
+ ('domain_match', self.gf('django.db.models.fields.TextField')()),
+ ))
+ db.send_create_signal('cluster', ['ACCluster'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'ACCluster'
+ db.delete_table('cluster_accluster')
+
+
+ models = {
+ 'cluster.accluster': {
+ 'Meta': {'object_name': 'ACCluster'},
+ 'api_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+ 'default_template_sco_id': ('django.db.models.fields.IntegerField', [], {'unique': 'True', 'blank': 'True'}),
+ 'domain_match': ('django.db.models.fields.TextField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+ 'user': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+ }
+ }
+
+ complete_apps = ['cluster']
diff --git a/meetingtools/apps/cluster/migrations/__init__.py b/meetingtools/apps/cluster/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/meetingtools/apps/cluster/migrations/__init__.py
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