# HG changeset patch # User Lennard de Rijk # Date 1251132218 -7200 # Node ID 14a62fcf4e02891849b29ad3e9a68a6e744ed01e # Parent c62f45595b8dbf568bbf89819d901efb329b7fce Added org taking access to Surveys. This taking access means that everyone with an active role for any organization for a given program can take the Survey. This will allow one Survey to be taken by both Org Admins and Mentors. diff -r c62f45595b8d -r 14a62fcf4e02 app/soc/models/survey.py --- a/app/soc/models/survey.py Mon Aug 24 20:22:45 2009 +0530 +++ b/app/soc/models/survey.py Mon Aug 24 18:43:38 2009 +0200 @@ -98,11 +98,8 @@ SURVEY_ACCESS = ['admin', 'restricted', 'member', 'user'] # these are GSoC specific, so eventually we can subclass this - SURVEY_TAKING_ACCESS = ['student', - 'mentor', - 'org_admin', - 'user'] - + SURVEY_TAKING_ACCESS = ['student', 'mentor', 'org_admin', 'org', 'user'] + GRADE_OPTIONS = {'midterm':['mid_term_passed', 'mid_term_failed'], 'final':['final_passed', 'final_failed'], 'N/A':[] } diff -r c62f45595b8d -r 14a62fcf4e02 app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Mon Aug 24 20:22:45 2009 +0530 +++ b/app/soc/views/helper/access.py Mon Aug 24 18:43:38 2009 +0200 @@ -1698,12 +1698,27 @@ return self._checkHasActiveRoleFor(django_args, mentor_logic, 'program') if role == 'org_admin': - # check if the current user is a mentor for the program in survey.scope + # check if the current user is an org admin for the program django_args['program'] = survey_scope # program is the 'program' attribute for mentors and org_admins return self._checkHasActiveRoleFor(django_args, org_admin_logic, 'program') + if role == 'org': + # check if the current user is an org admin or mentor for the program + django_args['program'] = survey_scope + + try: + # program is the 'program' attribute for mentors and org_admins + return self._checkHasActiveRoleFor(django_args, org_admin_logic, + 'program') + except: + # the current user is no org admin + pass + + # try to check if the current user is a mentor instead + return self._checkHasActiveRoleFor(django_args, mentor_logic, 'program') + if role == 'student': # check if the current user is a student for the program in survey.scope django_args['scope'] = survey_scope