Fixed access checkers for orgs
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 07 Feb 2009 23:26:38 +0000
changeset 1250 b06e6e014658
parent 1249 59d1e6b594ae
child 1251 106e1b6e7199
Fixed access checkers for orgs Patch by: Sverre Rabbelier, Lennard de Rijk
app/soc/views/helper/access.py
app/soc/views/models/org_app.py
--- a/app/soc/views/helper/access.py	Sat Feb 07 22:56:15 2009 +0000
+++ b/app/soc/views/helper/access.py	Sat Feb 07 23:26:38 2009 +0000
@@ -688,6 +688,20 @@
 
   @allowDeveloper
   @denySidebar
+  def checkIsHostForProgramInScope(self, django_args):
+    """Checks if the user is a host for the specified program.
+    """
+
+    program = program_logic.getFromKeyName(django_args['scope_path'])
+
+    if not program or program.status == 'invalid':
+      raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_PROGRAM_MSG)
+
+    django_args = {'scope_path': program.scope_path}
+    self.checkHasActiveRoleForScope(django_args, host_logic)
+
+  @allowDeveloper
+  @denySidebar
   def checkIsActivePeriod(self, django_args, period_name, key_name_arg):
     """Checks if the given period is active for the given program.
     
--- a/app/soc/views/models/org_app.py	Sat Feb 07 22:56:15 2009 +0000
+++ b/app/soc/views/models/org_app.py	Sat Feb 07 23:26:38 2009 +0000
@@ -61,9 +61,9 @@
     rights['public'] = [('checkCanEditGroupApp',
                        [org_app_logic.logic])]
     # TODO(ljvderijk) fix host access check
-    rights['review'] = ['checkIsHostForProgram',
+    rights['review'] = ['checkIsHostForProgramInScope',
                         ('checkCanReviewGroupApp', [org_app_logic.logic])]
-    rights['review_overview'] = ['checkIsHostForProgram']
+    rights['review_overview'] = ['checkIsHostForProgramInScope']
     rights['apply'] = ['checkIsUser',
                              ('checkCanCreateOrgApp', ['org_signup'])]