# HG changeset patch # User Lennard de Rijk # Date 1235826364 0 # Node ID 283046e54c0179a48ecf37a535833ab0ab0d586d # Parent 5ff25327371e7b13c2593f0b7f2a8caf25ad5ede Fixed issue 205. Registered students can't apply to become an organization. If for some reason the org sign up period and student sign up period are run in parallel and a student has applied to become an org, the application will still go through the normal system. Although the student won't be able to become an org admin until he has been invalidated as a student. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 5ff25327371e -r 283046e54c01 app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Sat Feb 28 12:59:34 2009 +0000 +++ b/app/soc/views/helper/access.py Sat Feb 28 13:06:04 2009 +0000 @@ -1064,6 +1064,39 @@ # no roles found, access granted return + def checkIsNotStudentForProgramInScope(self, django_args): + """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 + + Raises: + AccessViolationResponse: if the current user has a student + role for the given program. + """ + + if django_args.get('seed'): + key_name = django_args['seed']['scope_path'] + else: + key_name = django_args['scope_path'] + + program_entity = program_logic.getFromKeyName(key_name) + user_entity = user_logic.getForCurrentAccount() + + filter = {'user': user_entity, + 'scope': program_entity, + 'status': 'active'} + + # check if the current user is already a student for this program + student_role = student_logic.getForFields(filter, unique=True) + + if student_role: + raise out_of_band.AccessViolation( + message_fmt=DEF_ALREADY_PARTICIPATING_MSG) + + return + def checkIsNotStudentForProgramOfOrg(self, django_args): """Checks if the current user has no active Student role for the program that the organization in the scope_path is participating in. diff -r 5ff25327371e -r 283046e54c01 app/soc/views/models/org_app.py --- a/app/soc/views/models/org_app.py Sat Feb 28 12:59:34 2009 +0000 +++ b/app/soc/views/models/org_app.py Sat Feb 28 13:06:04 2009 +0000 @@ -75,7 +75,8 @@ rights['bulk_accept'] = ['checkIsHostForProgramInScope'] rights['bulk_reject'] = ['checkIsHostForProgramInScope'] rights['apply'] = ['checkIsUser', - ('checkCanCreateOrgApp', ['org_signup'])] + ('checkCanCreateOrgApp', ['org_signup']), + 'checkIsNotStudentForProgramInScope'] new_params = {}