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
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): """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.modules.gsoc.views.models.org_app_survey import view as org_app_view params['org_app_view'] = org_app_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') # 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, params['document_prefix'], 'survey'), "Create a New Survey", 'any_access')] # add link to list all Program Surveys items += [(redirects.getListSurveysRedirect( entity, params['document_prefix'], 'survey'), "List Surveys", 'any_access')] # add link to create a new Project Survey items += [(redirects.getCreateSurveyRedirect( entity, params['document_prefix'], 'gsoc/project_survey'), "Create a New Project Survey", 'any_access')] # add link to list all Project Surveys items += [(redirects.getListSurveysRedirect( entity, params['document_prefix'], 'gsoc/project_survey'), "List Project Surveys", 'any_access')] # add link to create a new Grading Survey items += [(redirects.getCreateSurveyRedirect( entity, params['document_prefix'], 'gsoc/grading_project_survey'), "Create a New Grading Survey", 'any_access')] # add link to list all Grading Surveys items += [(redirects.getListSurveysRedirect( entity, params['document_prefix'], 'gsoc/grading_project_survey'), "List Grading Surveys", 'any_access')] # add link to list all Grading Surveys items += [(redirects.getListRedirect( entity, {'url_name': 'gsoc/grading_survey_group'}), "List Grading Survey Groups", 'any_access')] # add link to view Student Projects items += [(redirects.getOverviewRedirect( entity, {'url_name': 'gsoc/student_project'}), "View all 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