def reviewPost(self, request, params, context, survey, record): """Handles the GET request for reviewing an OrgAppSurveyRecord. Args: request: HTTPRequest object params: View params dict context: page context dictionary survey: OrgAppSurvey entity record: OrgAppSurveyRecord under review """ survey_logic = params['logic'] record_logic = survey_logic.getRecordLogic() post_dict = request.POST review_form = params['review_form'](post_dict) if not review_form.is_valid(): context['review_form'] = review_form template = params['review_template'] return responses.respond(request, template, context) new_status = review_form.cleaned_data['status'] # only update if the status actually changes if record.status != new_status: fields = {'status': new_status} record_logic.updateEntityProperties(record, fields) return http.HttpResponseRedirect( redirects.getReviewOverviewRedirect(record.survey, params))
def reviewPost(self, request, params, context, survey, record): """Handles the GET request for reviewing an OrgAppSurveyRecord. Args: request: HTTPRequest object params: View params dict context: page context dictionary survey: OrgAppSurvey entity record: OrgAppSurveyRecord under review """ survey_logic = params['logic'] record_logic = survey_logic.getRecordLogic() post_dict = request.POST review_form = params['review_form'](post_dict) if not review_form.is_valid(): context['review_form'] = review_form template = params['review_template'] return responses.respond(request, template, context) new_status = review_form.cleaned_data['status'] # only update if the status actually changes if record.status != new_status: fields = {'status' : new_status} record_logic.updateEntityProperties(record, fields) return http.HttpResponseRedirect( redirects.getReviewOverviewRedirect(record.survey, params))
def _getHostEntries(self, entity, params, prefix): """Returns a list with menu items for program host. Args: entity: program entity to get the entries for params: view specific params prefix: module prefix for the program entity """ items = [] # add link to edit Program Profile items += [(redirects.getEditRedirect(entity, params), 'Edit Program Profile', 'any_access')] # add link to edit Program Timeline items += [ (redirects.getEditRedirect(entity, {'url_name': prefix + '/timeline'}), "Edit Program Timeline", 'any_access') ] # add link to create a new Program Document items += [ (redirects.getCreateDocumentRedirect(entity, params['document_prefix']), "Create a New Document", 'any_access') ] # add link to list all Program Document items += [ (redirects.getListDocumentsRedirect(entity, params['document_prefix']), "List Documents", 'any_access') ] # add link to list all participants items += [(redirects.getListParticipantsRedirect(entity, params), "List Participants", 'any_access')] # add link to Manage Statistics items += [(statistic_redirects.getManageRedirect(entity, params), 'Manage Statistics', 'any_access')] org_app_logic = params['org_app_logic'] org_app_survey = org_app_logic.getForProgram(entity) # add link to create/edit OrgAppSurvey items += [(redirects.getCreateSurveyRedirect(entity, params['document_prefix'], prefix + '/org_app'), 'Edit Org Application Survey', 'any_access')] if org_app_survey: # add link to Review Org Applications items += [(redirects.getReviewOverviewRedirect( org_app_survey, params['org_app_view'].getParams()), 'Review Organization Applications', 'any_access')] return items
def _getHostEntries(self, entity, params, prefix): """Returns a list with menu items for program host. Args: entity: program entity to get the entries for params: view specific params prefix: module prefix for the program entity """ items = [] # add link to edit Program Profile items += [(redirects.getEditRedirect(entity, params), 'Edit Program Profile', 'any_access')] # add link to edit Program Timeline items += [(redirects.getEditRedirect(entity, {'url_name': prefix + '/timeline'}), "Edit Program Timeline", 'any_access')] # add link to create a new Program Document items += [(redirects.getCreateDocumentRedirect( entity, params['document_prefix']), "Create a New Document", 'any_access')] # add link to list all Program Document items += [(redirects.getListDocumentsRedirect( entity, params['document_prefix']), "List Documents", 'any_access')] # add link to list all participants items += [(redirects.getListParticipantsRedirect(entity, params), "List Participants", 'any_access')] # add link to Manage Statistics items += [(statistic_redirects.getManageRedirect(entity, params), 'Manage Statistics', 'any_access')] org_app_logic = params['org_app_logic'] org_app_survey = org_app_logic.getForProgram(entity) # add link to create/edit OrgAppSurvey items += [(redirects.getCreateSurveyRedirect( entity, params['document_prefix'], prefix + '/org_app'), 'Edit Org Application Survey','any_access')] if org_app_survey: # add link to Review Org Applications items += [(redirects.getReviewOverviewRedirect( org_app_survey, params['org_app_view'].getParams()), 'Review Organization Applications', 'any_access')] return items
def getExtraMenus(self, id, user, params=None): """Returns the extra menu's for this view. A menu item is generated for each program that is currently running. The public page for each program is added as menu item, as well as all public documents for that program. Args: params: a dict with params for this View. """ from soc.views.models import survey as survey_view from soc.views.models import project_survey as project_survey_view from soc.views.models import grading_project_survey as grading_survey_view logic = params['logic'] rights = params['rights'] # only get all invisible and visible programs fields = {'status': ['invisible', 'visible']} entities = logic.getForFields(fields) menus = [] rights.setCurrentUser(id, user) for entity in entities: items = [] if entity.status == 'visible': # show the documents for this program, even for not logged in users items += document_view.view.getMenusForScope(entity, params) items += survey_view.view.getMenusForScope(entity, params, id, user) items += project_survey_view.view.getMenusForScope( entity, params, id, user) items += grading_survey_view.view.getMenusForScope( entity, params, id, user) items += self._getTimeDependentEntries(entity, params, id, user) try: # check if the current user is a host for this program rights.doCachedCheck('checkIsHostForProgram', {'scope_path': entity.scope_path, 'link_id': entity.link_id}, []) if entity.status == 'invisible': # still add the document links so hosts can see how it looks like items += document_view.view.getMenusForScope(entity, params) items += survey_view.view.getMenusForScope(entity, params, id, user) items += project_survey_view.view.getMenusForScope( entity, params, id, user) items += grading_survey_view.view.getMenusForScope( entity, params, id, user) items += self._getTimeDependentEntries(entity, params, id, user) items += [(redirects.getReviewOverviewRedirect( entity, {'url_name': 'org_app'}), "Review Organization Applications", 'any_access')] # add link to edit Program Profile items += [(redirects.getEditRedirect(entity, params), 'Edit Program Profile', 'any_access')] # add link to Assign Slots items += [(redirects.getAssignSlotsRedirect(entity, params), 'Assign Slots', 'any_access')] # add link to Show Duplicate project assignments items += [(redirects.getShowDuplicatesRedirect(entity, params), 'Show Duplicate Project Assignments', 'any_access')] # add link to edit Program Timeline items += [(redirects.getEditRedirect(entity, {'url_name': 'timeline'}), "Edit Program Timeline", 'any_access')] # add link to create a new Program Document items += [(redirects.getCreateDocumentRedirect(entity, 'program'), "Create a New Document", 'any_access')] # add link to list all Program Document items += [(redirects.getListDocumentsRedirect(entity, 'program'), "List Documents", 'any_access')] # add link to create a new Program Survey items += [(redirects.getCreateSurveyRedirect(entity, 'program', 'survey'), "Create a New Survey", 'any_access')] # add link to list all Program Surveys items += [(redirects.getListSurveysRedirect(entity, 'program', 'survey'), "List Surveys", 'any_access')] # add link to create a new Project Survey items += [(redirects.getCreateSurveyRedirect(entity, 'program', 'project_survey'), "Create a New Project Survey", 'any_access')] # add link to list all Project Surveys items += [(redirects.getListSurveysRedirect(entity, 'program', 'project_survey'), "List Project Surveys", 'any_access')] # add link to create a new Grading Survey items += [(redirects.getCreateSurveyRedirect(entity, 'program', 'grading_project_survey'), "Create a New Grading Survey", 'any_access')] # add link to list all Grading Surveys items += [(redirects.getListSurveysRedirect(entity, 'program', 'grading_project_survey'), "List Grading Surveys", 'any_access')] except out_of_band.Error: pass items = sidebar.getSidebarMenu(id, user, items, params=params) if not items: continue menu = {} menu['heading'] = entity.short_name menu['items'] = items menu['group'] = 'Programs' menus.append(menu) return menus
def getExtraMenus(self, id, user, params=None): """See soc.views.models.program.View.getExtraMenus(). """ # TODO: the largest part of this method can be moved to the core Program logic = params['logic'] rights = params['rights'] # only get all invisible and visible programs fields = {'status': ['invisible', 'visible']} entities = logic.getForFields(fields) menus = [] rights.setCurrentUser(id, user) for entity in entities: items = [] if entity.status == 'visible': # show the documents for this program, even for not logged in users items += document_view.view.getMenusForScope(entity, params) items += self._getTimeDependentEntries(entity, params, id, user) try: # check if the current user is a host for this program rights.doCachedCheck('checkIsHostForProgram', { 'scope_path': entity.scope_path, 'link_id': entity.link_id }, [logic]) if entity.status == 'invisible': # still add the document links so hosts can see how it looks like items += self._getTimeDependentEntries( entity, params, id, user) items += self._getHostEntries(entity, params, 'ghop') items += [(redirects.getReviewOverviewRedirect( entity, { 'url_name': 'ghop/org_app', 'scope_view': self }), "Review Organization Applications", 'any_access')] # add link to Assign Task Quota limits items += [(ghop_redirects.getAssignTaskQuotasRedirect( entity, params), 'Assign Task Quota limits', 'any_access')] # add link to edit Task Difficulty Levels items += [(ghop_redirects.getDifficultyEditRedirect( entity, {'url_name': 'ghop/program'}), "Edit Task Difficulty Levels", 'any_access')] # add link to edit Task Type Tags items += [(ghop_redirects.getTaskTypeEditRedirect( entity, {'url_name': 'ghop/program'}), "Edit Task Type Tags", 'any_access')] except out_of_band.Error: pass items = sidebar.getSidebarMenu(id, user, items, params=params) if not items: continue menu = {} menu['heading'] = entity.short_name menu['items'] = items menu['group'] = 'Programs' menus.append(menu) return menus
def getExtraMenus(self, id, user, params=None): """Returns the extra menu's for this view. A menu item is generated for each program that is currently running. The public page for each program is added as menu item, as well as all public documents for that program. Args: params: a dict with params for this View. """ # TODO: the largest part of this method can be moved to the core Program logic = params['logic'] rights = params['rights'] # only get all valid programs fields = {'status': ['invisible', 'visible', 'inactive']} entities = logic.getForFields(fields) menus = [] rights.setCurrentUser(id, user) for entity in entities: items = [] # some entries should be shown for all programs which are not hidden if entity.status in ['visible', 'inactive']: items += self._getStandardProgramEntries( entity, id, user, params) items += self._getSurveyEntries(entity, params, id, user) try: # check if the current user is a host for this program rights.doCachedCheck('checkIsHostForProgram', { 'scope_path': entity.scope_path, 'link_id': entity.link_id }, [logic]) if entity.status == 'invisible': # still add the standard entries so hosts can see how it looks like items += self._getStandardProgramEntries( entity, id, user, params) items += self._getSurveyEntries(entity, params, id, user) items += self._getHostEntries(entity, params, 'gsoc') items += [(redirects.getReviewOverviewRedirect( entity, {'url_name': 'org_app'}), "Review Organization Applications", 'any_access')] # add link to Assign Slots items += [(redirects.getAssignSlotsRedirect(entity, params), 'Assign Slots', 'any_access')] # add link to Show Duplicate project assignments items += [(redirects.getShowDuplicatesRedirect(entity, params), 'Show Duplicate Project Assignments', 'any_access')] # add link to create a new Program Survey items += [ (redirects.getCreateSurveyRedirect(entity, 'gsoc_program', 'survey'), "Create a New Survey", 'any_access') ] # add link to list all Program Surveys items += [ (redirects.getListSurveysRedirect(entity, 'gsoc_program', 'survey'), "List Surveys", 'any_access') ] # add link to create a new Project Survey items += [ (redirects.getCreateSurveyRedirect(entity, 'gsoc_program', 'gsoc/project_survey'), "Create a New Project Survey", 'any_access') ] # add link to list all Project Surveys items += [ (redirects.getListSurveysRedirect(entity, 'gsoc_program', 'gsoc/project_survey'), "List Project Surveys", 'any_access') ] # add link to create a new Grading Survey items += [(redirects.getCreateSurveyRedirect( entity, 'gsoc_program', 'gsoc/grading_project_survey'), "Create a New Grading Survey", 'any_access')] # add link to list all Grading Surveys items += [(redirects.getListSurveysRedirect( entity, 'gsoc_program', 'gsoc/grading_project_survey'), "List Grading Surveys", 'any_access')] # add link to withdraw Student Projects items += [(redirects.getWithdrawRedirect( entity, {'url_name': 'student_project'}), "Withdraw Student Projects", 'any_access')] except out_of_band.Error: pass items = sidebar.getSidebarMenu(id, user, items, params=params) if not items: continue menu = {} menu['heading'] = entity.short_name menu['items'] = items menu['group'] = 'Programs' menu[ 'collapse'] = 'collapse' if entity.status == 'inactive' else '' menus.append(menu) return menus