Added required program property to org_admin and mentor.
This can be used to simplify checks.
Patch by: Lennard de Rijk
Reviewed by: to-be-reviewed
--- a/app/soc/models/mentor.py Wed Feb 18 19:49:39 2009 +0000
+++ b/app/soc/models/mentor.py Wed Feb 18 21:41:27 2009 +0000
@@ -18,14 +18,19 @@
__authors__ = [
'"Todd Larsen" <tlarsen@google.com>',
+ '"Lennard de Rijk" <ljdverijk@gmail.com>',
]
+from google.appengine.ext import db
+import soc.models.program
import soc.models.role
class Mentor(soc.models.role.Role):
"""Organization Mentor.
"""
- pass
+ #: A required property that defines the program that this mentor works for
+ program = db.ReferenceProperty(reference_class=soc.models.program.Program,
+ required=True, collection_name='mentors')
--- a/app/soc/models/org_admin.py Wed Feb 18 19:49:39 2009 +0000
+++ b/app/soc/models/org_admin.py Wed Feb 18 21:41:27 2009 +0000
@@ -17,14 +17,21 @@
"""This module contains the Organization Administrator Model."""
__authors__ = [
+ '"Lennard de Rijk" <ljvderijk@gmail.com>',
'"Pawel Solyga" <pawel.solyga@gmail.com>',
]
+from google.appengine.ext import db
+
+import soc.models.program
import soc.models.role
class OrgAdmin(soc.models.role.Role):
"""Administrator details for a specific Organization.
"""
- pass
+
+ #: A required property that defines the program that this org admin works for
+ program = db.ReferenceProperty(reference_class=soc.models.program.Program,
+ required=True, collection_name='org_admins')
--- a/app/soc/views/models/mentor.py Wed Feb 18 19:49:39 2009 +0000
+++ b/app/soc/views/models/mentor.py Wed Feb 18 21:41:27 2009 +0000
@@ -79,7 +79,7 @@
new_params['module_name'] = "mentor"
new_params['sidebar_grouping'] = 'Organizations'
- new_params['extra_dynaexclude'] = ['agreed_to_tos']
+ new_params['extra_dynaexclude'] = ['agreed_to_tos', 'program']
new_params['create_extra_dynafields'] = {
'scope_path': forms.fields.CharField(widget=forms.HiddenInput,
@@ -122,6 +122,10 @@
fields['user'] = fields['link_id']
fields['link_id'] = fields['user'].link_id
+ group_logic = params['group_logic']
+ group_entity = group_logic.getFromKeyName(fields['scope_path'])
+ fields['program'] = group_entity.scope
+
fields['agreed_to_tos'] = fields['agreed_to_mentor_agreement']
super(View, self)._editPost(request, entity, fields)
@@ -137,6 +141,10 @@
fields['link_id'] = fields['user'].link_id
fields['agreed_to_tos'] = fields['agreed_to_mentor_agreement']
+ group_logic = params['group_logic']
+ group_entity = group_logic.getFromKeyName(fields['scope_path'])
+ fields['program'] = group_entity.scope
+
def _editGet(self, request, entity, form):
"""Sets the content of the agreed_to_tos_on field and replaces.
--- a/app/soc/views/models/org_admin.py Wed Feb 18 19:49:39 2009 +0000
+++ b/app/soc/views/models/org_admin.py Wed Feb 18 21:41:27 2009 +0000
@@ -82,7 +82,7 @@
new_params['module_name'] = "org_admin"
new_params['sidebar_grouping'] = 'Organizations'
- new_params['extra_dynaexclude'] = ['agreed_to_tos']
+ new_params['extra_dynaexclude'] = ['agreed_to_tos', 'program']
new_params['create_extra_dynafields'] = {
'scope_path': forms.fields.CharField(widget=forms.HiddenInput,
@@ -125,6 +125,9 @@
if not entity:
fields['user'] = fields['link_id']
fields['link_id'] = fields['user'].link_id
+ group_logic = params['group_logic']
+ group_entity = group_logic.getFromKeyName(fields['scope_path'])
+ fields['program'] = group_entity.scope
fields['agreed_to_tos'] = fields['agreed_to_admin_agreement']
@@ -141,6 +144,10 @@
fields['link_id'] = fields['user'].link_id
fields['agreed_to_tos'] = fields['agreed_to_admin_agreement']
+ group_logic = params['group_logic']
+ group_entity = group_logic.getFromKeyName(fields['scope_path'])
+ fields['program'] = group_entity.scope
+
def _editGet(self, request, entity, form):
"""Sets the content of the agreed_to_tos_on field and replaces.