# HG changeset patch # User Sverre Rabbelier # Date 1233594151 0 # Node ID 14357ec136470dea6264aae9a72894dbf4eebdd1 # Parent d40ace54d14b9745300bfebf4b9db15654a21a89 More access related fixes Also make it possible to do access checks for 'create'. Patch by: Sverre Rabbelier diff -r d40ace54d14b -r 14357ec13647 app/soc/views/helper/access.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. diff -r d40ace54d14b -r 14357ec13647 app/soc/views/models/club.py --- 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'] diff -r d40ace54d14b -r 14357ec13647 app/soc/views/models/program.py --- 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'] diff -r d40ace54d14b -r 14357ec13647 app/soc/views/models/sponsor.py --- 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