# HG changeset patch # User Lennard de Rijk # Date 1233504849 0 # Node ID 77276e2c46f7346f1471645089126f54efea0b6c # Parent 4804f7f5a7c03bc0f83508a70ea78cee08ccbaef Implement the last step in the org application process. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed 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() diff -r 4804f7f5a7c0 -r 77276e2c46f7 app/soc/views/models/organization.py --- a/app/soc/views/models/organization.py Sun Feb 01 16:11:54 2009 +0000 +++ b/app/soc/views/models/organization.py Sun Feb 01 16:14:09 2009 +0000 @@ -27,8 +27,11 @@ from soc.logic import cleaning from soc.logic import dicts +from soc.logic.models import org_app as org_app_logic from soc.views.helper import access +from soc.views.helper import dynaform from soc.views.helper import redirects +from soc.views.helper import widgets from soc.views.models import group from soc.views.models import program as program_view @@ -57,8 +60,7 @@ rights['list'] = ['checkIsDeveloper'] rights['list_requests'] = ['checkIsDeveloper'] rights['list_roles'] = ['checkIsDeveloper'] - # TODO(ljvderijk) implement Org application process - #rights['applicant'] = ['checkIsDeveloper'] + rights['applicant'] = ['checkIsDeveloper'] new_params = {} new_params['logic'] = soc.logic.models.organization.logic @@ -74,6 +76,9 @@ new_params['list_row'] = 'soc/organization/list/row.html' new_params['list_heading'] = 'soc/organization/list/heading.html' + new_params['application_logic'] = org_app_logic + new_params['group_applicant_url'] = True + #TODO(ljvderijk) add cleaning methods to not overwrite existing orgs new_params['create_extra_dynafields'] = { 'scope_path': forms.CharField(widget=forms.HiddenInput, @@ -85,12 +90,26 @@ super(View, self).__init__(params=params) + # create and store the special form for applicants + updated_fields = { + 'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), + required=False), + 'clean_link_id': cleaning.clean_link_id('link_id')} + + applicant_create_form = dynaform.extendDynaForm( + dynaform = self._params['create_form'], + dynafields = updated_fields) + + params['applicant_create_form'] = applicant_create_form + + # TODO(ljvderijk) define several menu items for organizations #def _getExtraMenuItems(self, role_description, params=None): view = View() +applicant = view.applicant create = view.create delete = view.delete edit = view.edit