More access related fixes
authorSverre Rabbelier <srabbelier@gmail.com>
Mon, 02 Feb 2009 17:02:31 +0000
changeset 1189 14357ec13647
parent 1188 d40ace54d14b
child 1190 449b9d93d890
More access related fixes Also make it possible to do access checks for 'create'. Patch by: Sverre Rabbelier
app/soc/views/helper/access.py
app/soc/views/models/club.py
app/soc/views/models/program.py
app/soc/views/models/sponsor.py
--- a/app/soc/views/helper/access.py	Mon Feb 02 16:57:21 2009 +0000
+++ b/app/soc/views/helper/access.py	Mon Feb 02 17:02:31 2009 +0000
@@ -558,6 +558,13 @@
     django_args['user'] = self.user
     self.checkIsActive(django_args, logic, field_name, 'user')
 
+  def checkSeeded(self, django_args, checker_name, *args):
+    """Wrapper to update the django_args with the contens of seed first.
+    """
+
+    django_args.update(django_args.get('seed', {}))
+    self.doCheck(checker_name, django_args, args)
+
   def checkCanMakeRequestToGroup(self, django_args, group_logic):
     """Raises an alternate HTTP response if the specified group is not in an
     active status.
--- a/app/soc/views/models/club.py	Mon Feb 02 16:57:21 2009 +0000
+++ b/app/soc/views/models/club.py	Mon Feb 02 17:02:31 2009 +0000
@@ -58,8 +58,8 @@
 
     rights = access.Checker(params)
     rights['create'] = ['checkIsDeveloper']
-    rights['edit'] = [('checkHasRole', club_admin_logic.logic),
-                      ('checkIsActive', club_logic.logic)]
+    rights['edit'] = [('checkHasRole', [club_admin_logic.logic, 'link_id']),
+                      ('checkIsActive', [club_logic.logic, None])]
     rights['delete'] = ['checkIsDeveloper']
     rights['home'] = ['allow']
     rights['list'] = ['checkIsDeveloper']
--- a/app/soc/views/models/program.py	Mon Feb 02 16:57:21 2009 +0000
+++ b/app/soc/views/models/program.py	Mon Feb 02 17:02:31 2009 +0000
@@ -57,7 +57,7 @@
     rights = access.Checker(params)
     rights['any_access'] = ['allow']
     rights['show'] = ['allow']
-    rights['create'] = [('checkHasRole', host_logic.logic)]
+    rights['create'] = [('checkSeeded', ['checkHasRole', host_logic.logic])]
     rights['edit'] = ['checkIsHostForProgram']
     rights['delete'] = ['checkIsDeveloper']
 
--- a/app/soc/views/models/sponsor.py	Mon Feb 02 16:57:21 2009 +0000
+++ b/app/soc/views/models/sponsor.py	Mon Feb 02 17:02:31 2009 +0000
@@ -26,6 +26,7 @@
 
 from soc.logic import dicts
 from soc.logic.models.sponsor import logic as sponsor_logic
+from soc.logic.models.host import logic as host_logic
 from soc.views.helper import access
 from soc.views.helper import redirects
 from soc.views.models import group
@@ -49,13 +50,13 @@
 
     rights = access.Checker(params)
     rights['create'] = ['checkIsDeveloper']
-    rights['edit'] = [('checkHasRole', sponsor_logic),
-                      ('checkIsActive', sponsor_logic)]
+    rights['edit'] = [('checkHasRole', [host_logic, 'link_id']),
+                      ('checkIsActive', [sponsor_logic, None, 'link_id'])]
     rights['delete'] = ['checkIsDeveloper']
-    rights['home'] = [('checkHasRole', sponsor_logic)]
+    rights['home'] = [('checkHasRole', host_logic)]
     rights['list'] = ['checkIsDeveloper']
-    rights['list_requests'] = [('checkHasRole', sponsor_logic)]
-    rights['list_roles'] = [('checkHasRole', sponsor_logic)]
+    rights['list_requests'] = [('checkHasRole', [host_logic, 'link_id'])]
+    rights['list_roles'] = [('checkHasRole', [host_logic, 'link_id'])]
 
     new_params = {}
     new_params['logic'] = soc.logic.models.sponsor.logic