# HG changeset patch # User Lennard de Rijk # Date 1247400215 -7200 # Node ID 95949d4c45d9e7c52fe843ed658fea86b6d5a294 # Parent dc0d4c3d9d2e94bde3fd6235bc93ff5f273e2881 Add scope view for GradingSurveyGroup and set access checks. The access checks are now properly set for create, edit and show. To facilitate the scope view the access check have an extra check built in to ensure that a scope is actually present before cheking for an existing Program. diff -r dc0d4c3d9d2e -r 95949d4c45d9 app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Sun Jul 12 13:55:21 2009 +0200 +++ b/app/soc/views/helper/access.py Sun Jul 12 14:03:35 2009 +0200 @@ -939,7 +939,7 @@ @denySidebar def checkIsHostForProgram(self, django_args): """Checks if the user is a host for the specified program. - + Args: django_args: a dictionary with django's arguments """ @@ -956,12 +956,17 @@ @denySidebar def checkIsHostForProgramInScope(self, django_args): """Checks if the user is a host for the specified program. - + Args: django_args: a dictionary with django's arguments """ - program = program_logic.getFromKeyName(django_args['scope_path']) + scope_path = django_args.get('scope_path') + + if not scope_path: + raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_DENIED_MSG) + + program = program_logic.getFromKeyName(scope_path) if not program or program.status == 'invalid': raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_PROGRAM_MSG) diff -r dc0d4c3d9d2e -r 95949d4c45d9 app/soc/views/models/grading_survey_group.py --- a/app/soc/views/models/grading_survey_group.py Sun Jul 12 13:55:21 2009 +0200 +++ b/app/soc/views/models/grading_survey_group.py Sun Jul 12 14:03:35 2009 +0200 @@ -42,6 +42,7 @@ from soc.views.helper import decorators from soc.views.helper import redirects from soc.views.models import base +from soc.views.models import program as program_view class View(base.View): @@ -57,10 +58,10 @@ """ rights = access.Checker(params) - rights['create'] = ['checkIsDeveloper'] - rights['edit'] = ['checkIsDeveloper'] + rights['create'] = ['checkIsHostForProgramInScope'] + rights['edit'] = ['checkIsHostForProgramInScope'] rights['delete'] = ['checkIsDeveloper'] - rights['show'] = ['checkIsDeveloper'] + rights['show'] = ['checkIsHostForProgramInScope'] rights['list'] = ['checkIsDeveloper'] new_params = {} @@ -69,8 +70,10 @@ new_params['name'] = "Grading Survey Group" new_params['sidebar_grouping'] = "Surveys" + new_params['scope_view'] = program_view + new_params['scope_redirect'] = redirects.getCreateRedirect + new_params['no_admin'] = True - new_params['no_create_raw'] = True new_params['no_create_with_key_fields'] = True new_params['create_extra_dynaproperties'] = { @@ -101,7 +104,8 @@ For params see base.View.create(). """ - self.setQueries(kwargs['scope_path'], params['create_form']) + if kwargs.get('scope_path'): + self.setQueries(kwargs['scope_path'], params['create_form']) return super(View, self).create(request, access_type, page_name=page_name, params=params, **kwargs)