# HG changeset patch # User Madhusudan.C.S # Date 1250892853 -19800 # Node ID 8f6c0a5a749124d67f9d2da343cc209003639000 # Parent 0362fb7e3b3c832904047ab0f8b7ef3bedf34efb program_logic is passed as a parameter to three checkers than hard coding it. program_logic is added as a parameter to checkIsActivePeriod checkCanCreateOrgApp checkIsNotParticipatingInProgramInScope access check methods and the corresponding arguments are added in all the places they are used. diff -r 0362fb7e3b3c -r 8f6c0a5a7491 app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Mon Aug 17 18:47:48 2009 +0200 +++ b/app/soc/views/helper/access.py Sat Aug 22 03:44:13 2009 +0530 @@ -982,7 +982,8 @@ @allowDeveloper @denySidebar - def checkIsActivePeriod(self, django_args, period_name, key_name_arg): + def checkIsActivePeriod(self, django_args, period_name, + key_name_arg, program_logic): """Checks if the given period is active for the given program. Args: @@ -991,6 +992,7 @@ key_name_arg: the entry in django_args that specifies the given program keyname. If none is given the key_name is constructed from django_args itself. + program_logic: Program Logic instance Raises: AccessViolationResponse: @@ -1050,17 +1052,18 @@ raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG) - def checkCanCreateOrgApp(self, django_args, period_name): + def checkCanCreateOrgApp(self, django_args, period_name, program_logic): """Checks to see if the program in the scope_path is accepting org apps Args: django_args: a dictionary with django's arguments period_name: the name of the period which is checked + program_logic: Program Logic instance """ if 'seed' in django_args: return self.checkIsActivePeriod(django_args['seed'], - period_name, 'scope_path') + period_name, 'scope_path', program_logic) else: return @@ -1161,12 +1164,13 @@ raise out_of_band.AccessViolation(message_fmt=DEF_NO_APPLICATION_MSG) - def checkIsNotParticipatingInProgramInScope(self, django_args): + def checkIsNotParticipatingInProgramInScope(self, django_args, program_logic): """Checks if the current user has no roles for the given program in django_args. Args: django_args: a dictionary with django's arguments + program_logic: Program Logic instance Raises: AccessViolationResponse: if the current user has a student, mentor or @@ -1213,12 +1217,13 @@ # no roles found, access granted return - def checkIsNotStudentForProgramInScope(self, django_args): + def checkIsNotStudentForProgramInScope(self, django_args, program_logic): """Checks if the current user is not a student for the given program in django_args. Args: django_args: a dictionary with django's arguments + program_logic: Program Logic instance Raises: AccessViolationResponse: if the current user has a student diff -r 0362fb7e3b3c -r 8f6c0a5a7491 app/soc/views/models/org_app.py --- a/app/soc/views/models/org_app.py Mon Aug 17 18:47:48 2009 +0200 +++ b/app/soc/views/models/org_app.py Sat Aug 22 03:44:13 2009 +0530 @@ -60,10 +60,12 @@ rights['create'] = ['checkIsDeveloper'] rights['delete'] = [('checkCanEditGroupApp', [org_app_logic.logic]), - ('checkIsActivePeriod', ['org_signup', 'scope_path'])] + ('checkIsActivePeriod', + ['org_signup', 'scope_path', program_logic.logic])] rights['edit'] = [('checkCanEditGroupApp', [org_app_logic.logic]), - ('checkIsActivePeriod', ['org_signup', 'scope_path'])] + ('checkIsActivePeriod', + ['org_signup', 'scope_path', program_logic.logic])] rights['list'] = ['checkIsDeveloper'] rights['list_self'] = ['checkIsUser'] rights['show'] = ['allow'] @@ -73,7 +75,8 @@ rights['bulk_accept'] = ['checkIsHostForProgramInScope'] rights['bulk_reject'] = ['checkIsHostForProgramInScope'] rights['apply'] = ['checkIsUser', - ('checkCanCreateOrgApp', ['org_signup']), + ('checkCanCreateOrgApp', + ['org_signup', program_logic.logic]), 'checkIsNotStudentForProgramInScope'] new_params = {} diff -r 0362fb7e3b3c -r 8f6c0a5a7491 app/soc/views/models/student.py --- a/app/soc/views/models/student.py Mon Aug 17 18:47:48 2009 +0200 +++ b/app/soc/views/models/student.py Sat Aug 22 03:44:13 2009 +0530 @@ -65,8 +65,9 @@ rights['delete'] = ['checkIsDeveloper'] rights['apply'] = [ 'checkIsUser', - ('checkIsActivePeriod', ['student_signup', 'scope_path']), - 'checkIsNotParticipatingInProgramInScope', + ('checkIsActivePeriod', + ['student_signup', 'scope_path', program_logic.logic]), + ('checkIsNotParticipatingInProgramInScope', [program_logic.logic]), ] rights['manage'] = [('checkHasActiveRoleForScope', student_logic.logic), ('checkIsMyEntity', [student_logic.logic, 'user', True])]