187 items = [] |
187 items = [] |
188 |
188 |
189 if entity.status == 'visible': |
189 if entity.status == 'visible': |
190 # show the documents for this program, even for not logged in users |
190 # show the documents for this program, even for not logged in users |
191 items += document_view.view.getMenusForScope(entity, params) |
191 items += document_view.view.getMenusForScope(entity, params) |
192 items += self._getTimeDependentEntries(entity, params) |
192 items += self._getTimeDependentEntries(entity, params, id, user) |
193 |
193 |
194 try: |
194 try: |
195 # check if the current user is a host for this program |
195 # check if the current user is a host for this program |
196 rights.doCachedCheck('checkIsHostForProgram', |
196 rights.doCachedCheck('checkIsHostForProgram', |
197 {'scope_path': entity.scope_path, |
197 {'scope_path': entity.scope_path, |
212 items += [(redirects.getEditRedirect(entity, {'url_name': 'timeline'}), |
212 items += [(redirects.getEditRedirect(entity, {'url_name': 'timeline'}), |
213 "Edit Program Timeline", 'any_access')] |
213 "Edit Program Timeline", 'any_access')] |
214 # add link to create a new Program Document |
214 # add link to create a new Program Document |
215 items += [(redirects.getCreateDocumentRedirect(entity, 'program'), |
215 items += [(redirects.getCreateDocumentRedirect(entity, 'program'), |
216 "Create a New Document", 'any_access')] |
216 "Create a New Document", 'any_access')] |
|
217 # add link to list all Program Document |
|
218 items += [(redirects.getListDocumentsRedirect(entity, 'program'), |
|
219 "List Documents", 'any_access')] |
217 |
220 |
218 except out_of_band.Error: |
221 except out_of_band.Error: |
219 pass |
222 pass |
220 |
223 |
221 items = sidebar.getSidebarMenu(id, user, items, params=params) |
224 items = sidebar.getSidebarMenu(id, user, items, params=params) |
228 menu['group'] = 'Programs' |
231 menu['group'] = 'Programs' |
229 menus.append(menu) |
232 menus.append(menu) |
230 |
233 |
231 return menus |
234 return menus |
232 |
235 |
233 def _getTimeDependentEntries(self, program_entity, params): |
236 def _getTimeDependentEntries(self, program_entity, params, id, user): |
234 items = [] |
237 items = [] |
235 |
238 |
236 #TODO(ljvderijk) Add more timeline dependent entries |
239 #TODO(ljvderijk) Add more timeline dependent entries |
237 timeline_entity = program_entity.timeline |
240 timeline_entity = program_entity.timeline |
238 |
241 |
239 if timeline_helper.isActivePeriod(timeline_entity, 'org_signup'): |
242 if user and timeline_helper.isActivePeriod(timeline_entity, 'org_signup'): |
240 # add the organization signup link |
243 # add the organization signup link |
241 items += [ |
244 items += [ |
242 (redirects.getApplyRedirect(program_entity, {'url_name': 'org_app'}), |
245 (redirects.getApplyRedirect(program_entity, {'url_name': 'org_app'}), |
243 "Apply to become an Organization", 'any_access')] |
246 "Apply to become an Organization", 'any_access')] |
244 |
247 |
|
248 # add the 'list my orgs' link |
245 items += [ |
249 items += [ |
246 (redirects.getListSelfRedirect(program_entity, {'url_name' : 'org_app'}), |
250 (redirects.getListSelfRedirect(program_entity, {'url_name' : 'org_app'}), |
247 "List my Org Applications", 'any_access')] |
251 "List my Org Applications", 'any_access')] |
248 |
252 |
249 return items |
253 return items |