980 django_args = {'scope_path': program.scope_path} |
980 django_args = {'scope_path': program.scope_path} |
981 self.checkHasActiveRoleForScope(django_args, host_logic) |
981 self.checkHasActiveRoleForScope(django_args, host_logic) |
982 |
982 |
983 @allowDeveloper |
983 @allowDeveloper |
984 @denySidebar |
984 @denySidebar |
985 def checkIsActivePeriod(self, django_args, period_name, key_name_arg): |
985 def checkIsActivePeriod(self, django_args, period_name, |
|
986 key_name_arg, program_logic): |
986 """Checks if the given period is active for the given program. |
987 """Checks if the given period is active for the given program. |
987 |
988 |
988 Args: |
989 Args: |
989 django_args: a dictionary with django's arguments |
990 django_args: a dictionary with django's arguments |
990 period_name: the name of the period which is checked |
991 period_name: the name of the period which is checked |
991 key_name_arg: the entry in django_args that specifies the given program |
992 key_name_arg: the entry in django_args that specifies the given program |
992 keyname. If none is given the key_name is constructed from django_args |
993 keyname. If none is given the key_name is constructed from django_args |
993 itself. |
994 itself. |
|
995 program_logic: Program Logic instance |
994 |
996 |
995 Raises: |
997 Raises: |
996 AccessViolationResponse: |
998 AccessViolationResponse: |
997 * if no active Program is found |
999 * if no active Program is found |
998 * if the period is not active |
1000 * if the period is not active |
1048 if timeline_helper.isAfterEvent(program_entity.timeline, event_name): |
1050 if timeline_helper.isAfterEvent(program_entity.timeline, event_name): |
1049 return |
1051 return |
1050 |
1052 |
1051 raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG) |
1053 raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG) |
1052 |
1054 |
1053 def checkCanCreateOrgApp(self, django_args, period_name): |
1055 def checkCanCreateOrgApp(self, django_args, period_name, program_logic): |
1054 """Checks to see if the program in the scope_path is accepting org apps |
1056 """Checks to see if the program in the scope_path is accepting org apps |
1055 |
1057 |
1056 Args: |
1058 Args: |
1057 django_args: a dictionary with django's arguments |
1059 django_args: a dictionary with django's arguments |
1058 period_name: the name of the period which is checked |
1060 period_name: the name of the period which is checked |
|
1061 program_logic: Program Logic instance |
1059 """ |
1062 """ |
1060 |
1063 |
1061 if 'seed' in django_args: |
1064 if 'seed' in django_args: |
1062 return self.checkIsActivePeriod(django_args['seed'], |
1065 return self.checkIsActivePeriod(django_args['seed'], |
1063 period_name, 'scope_path') |
1066 period_name, 'scope_path', program_logic) |
1064 else: |
1067 else: |
1065 return |
1068 return |
1066 |
1069 |
1067 @allowDeveloper |
1070 @allowDeveloper |
1068 def checkCanEditGroupApp(self, django_args, group_app_logic): |
1071 def checkCanEditGroupApp(self, django_args, group_app_logic): |
1159 backup_admin == user): |
1162 backup_admin == user): |
1160 return |
1163 return |
1161 |
1164 |
1162 raise out_of_band.AccessViolation(message_fmt=DEF_NO_APPLICATION_MSG) |
1165 raise out_of_band.AccessViolation(message_fmt=DEF_NO_APPLICATION_MSG) |
1163 |
1166 |
1164 def checkIsNotParticipatingInProgramInScope(self, django_args): |
1167 def checkIsNotParticipatingInProgramInScope(self, django_args, program_logic): |
1165 """Checks if the current user has no roles for the given |
1168 """Checks if the current user has no roles for the given |
1166 program in django_args. |
1169 program in django_args. |
1167 |
1170 |
1168 Args: |
1171 Args: |
1169 django_args: a dictionary with django's arguments |
1172 django_args: a dictionary with django's arguments |
|
1173 program_logic: Program Logic instance |
1170 |
1174 |
1171 Raises: |
1175 Raises: |
1172 AccessViolationResponse: if the current user has a student, mentor or |
1176 AccessViolationResponse: if the current user has a student, mentor or |
1173 org admin role for the given program. |
1177 org admin role for the given program. |
1174 """ |
1178 """ |
1211 message_fmt=DEF_ALREADY_PARTICIPATING_MSG) |
1215 message_fmt=DEF_ALREADY_PARTICIPATING_MSG) |
1212 |
1216 |
1213 # no roles found, access granted |
1217 # no roles found, access granted |
1214 return |
1218 return |
1215 |
1219 |
1216 def checkIsNotStudentForProgramInScope(self, django_args): |
1220 def checkIsNotStudentForProgramInScope(self, django_args, program_logic): |
1217 """Checks if the current user is not a student for the given |
1221 """Checks if the current user is not a student for the given |
1218 program in django_args. |
1222 program in django_args. |
1219 |
1223 |
1220 Args: |
1224 Args: |
1221 django_args: a dictionary with django's arguments |
1225 django_args: a dictionary with django's arguments |
|
1226 program_logic: Program Logic instance |
1222 |
1227 |
1223 Raises: |
1228 Raises: |
1224 AccessViolationResponse: if the current user has a student |
1229 AccessViolationResponse: if the current user has a student |
1225 role for the given program. |
1230 role for the given program. |
1226 """ |
1231 """ |