diff -r 4804f7f5a7c0 -r 77276e2c46f7 app/soc/logic/models/organization.py --- a/app/soc/logic/models/organization.py Sun Feb 01 16:11:54 2009 +0000 +++ b/app/soc/logic/models/organization.py Sun Feb 01 16:14:09 2009 +0000 @@ -19,12 +19,15 @@ __authors__ = [ '"Sverre Rabbelier" ', + '"Lennard de Rijk" ', ] from soc.logic.models import base from soc.logic.models import group +from soc.logic.models import org_app as org_app_logic from soc.logic.models import program as program_logic +from soc.logic.models import request as request_logic import soc.models.group import soc.models.organization @@ -48,4 +51,37 @@ getKeyFieldNames = base.Logic.getKeyFieldNames + def _onCreate(self, entity): + """Invites the group admin and backup admin. + """ + + fields = { + 'link_id': entity.link_id, + 'scope_path': entity.scope_path + } + + # Find their application + application = org_app_logic.logic.getFromKeyFields(fields) + + if application: + # only if there is an application send out the invites + properties = { + 'scope': entity, + 'scope_path': entity.key().name(), + 'role': 'org_admin', + 'role_verbose' : 'Organization Admin', + 'status': 'group_accepted', + } + + for admin in [application.applicant, application.backup_admin]: + properties['link_id'] = admin.link_id + key_fields = request_logic.logic.getKeyFieldsFromFields(properties) + request_logic.logic.updateOrCreateFromFields(properties, key_fields) + + # set the application to completed + fields = {'status' : 'completed'} + org_app_logic.logic.updateEntityProperties(application, fields) + + super(Logic, self)._onCreate(entity) + logic = Logic()