Invite (backup-)admin when creating a club
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 10 Jan 2009 18:17:44 +0000
changeset 801 06a84103ed8b
parent 800 738f6335b0e2
child 802 95c534d02e39
Invite (backup-)admin when creating a club Patch by: Sverre Rabbelier
app/soc/logic/models/club.py
--- a/app/soc/logic/models/club.py	Sat Jan 10 18:17:30 2009 +0000
+++ b/app/soc/logic/models/club.py	Sat Jan 10 18:17:44 2009 +0000
@@ -18,11 +18,14 @@
 """
 
 __authors__ = [
-  '"Lennard de Rijk" <ljvderijk@gmail.com>',
+    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+    '"Lennard de Rijk" <ljvderijk@gmail.com>',
   ]
 
 
 from soc.logic.models import group
+from soc.logic.models import group_app as group_app_logic
+from soc.logic.models import request as request_logic
 
 import soc.models.club
 import soc.models.group
@@ -40,5 +43,24 @@
     super(Logic, self).__init__(model, base_model=base_model,
                                 scope_logic=scope_logic)
 
+  def _onCreate(self, entity):
+    """Invites the org admin and backup admin
+    """
+
+    # Find their application
+    application = group_app_logic.logic.getFromFields(link_id=entity.link_id)
+
+    properties = {
+        'scope': entity,
+        'scope_path': entity.key().name(),
+        'role': 'club_admin',
+        'group_accepted': True,
+        }
+
+    for admin in [application.applicant, application.backup_admin]:
+      properties['link_id'] = admin.link_id
+      key_fields = request_logic.logic.getKeyFieldsFromDict(properties)
+      request_logic.logic.updateOrCreateFromFields(properties, key_fields)
+
 
 logic = Logic()