24 |
24 |
25 |
25 |
26 from django import forms |
26 from django import forms |
27 |
27 |
28 from soc.logic import dicts |
28 from soc.logic import dicts |
|
29 from soc.logic.helper import timeline as timeline_helper |
29 from soc.logic.models import program as program_logic |
30 from soc.logic.models import program as program_logic |
30 from soc.logic.models import host as host_logic |
31 from soc.logic.models import host as host_logic |
31 from soc.views import helper |
32 from soc.views import helper |
32 from soc.views import out_of_band |
33 from soc.views import out_of_band |
33 from soc.views.helper import access |
34 from soc.views.helper import access |
139 |
140 |
140 # only get all invisible and visible programs |
141 # only get all invisible and visible programs |
141 fields = {'status':['invisible', 'visible']} |
142 fields = {'status':['invisible', 'visible']} |
142 entities = logic.getForFields(fields) |
143 entities = logic.getForFields(fields) |
143 |
144 |
144 #TODO(ljvderijk) Add timeline dependent entries |
|
145 |
|
146 menus = [] |
145 menus = [] |
147 |
146 |
148 rights.setCurrentUser(id, user) |
147 rights.setCurrentUser(id, user) |
149 filter_args = {} |
148 filter_args = {} |
150 |
149 |
152 items = [] |
151 items = [] |
153 |
152 |
154 if entity.status == 'visible': |
153 if entity.status == 'visible': |
155 # show the documents for this program, even for not logged in users |
154 # show the documents for this program, even for not logged in users |
156 items += document_view.view.getMenusForScope(entity, params) |
155 items += document_view.view.getMenusForScope(entity, params) |
|
156 items += self._getTimeDependentEntries(entity, params) |
157 |
157 |
158 try: |
158 try: |
159 # check if the current user is a host for this program |
159 # check if the current user is a host for this program |
160 rights.doCachedCheck('checkIsHostForProgram', |
160 rights.doCachedCheck('checkIsHostForProgram', |
161 {'scope_path': entity.scope_path, |
161 {'scope_path': entity.scope_path, |
162 'link_id': entity.link_id}, []) |
162 'link_id': entity.link_id}, []) |
163 |
163 |
164 if entity.status == 'invisible': |
164 if entity.status == 'invisible': |
165 # still add the document links so hosts can see how it looks like |
165 # still add the document links so hosts can see how it looks like |
166 items += document_view.view.getMenusForScope(entity, params) |
166 items += document_view.view.getMenusForScope(entity, params) |
|
167 items += self._getTimeDependentEntries(entity, params) |
167 |
168 |
168 # add link to edit Program Profile |
169 # add link to edit Program Profile |
169 items += [(redirects.getEditRedirect(entity, params), |
170 items += [(redirects.getEditRedirect(entity, params), |
170 'Edit Program Profile','any_access')] |
171 'Edit Program Profile','any_access')] |
171 # add link to edit Program Timeline |
172 # add link to edit Program Timeline |
188 menu['group'] = 'Programs' |
189 menu['group'] = 'Programs' |
189 menus.append(menu) |
190 menus.append(menu) |
190 |
191 |
191 return menus |
192 return menus |
192 |
193 |
|
194 def _getTimeDependentEntries(self, program_entity, params): |
|
195 items = [] |
|
196 |
|
197 #TODO(ljvderijk) Add more timeline dependent entries |
|
198 timeline_entity = program_entity.timeline |
|
199 |
|
200 if timeline_helper.isActivePeriod(timeline_entity, 'org_signup'): |
|
201 # add the organization signup link |
|
202 items += [ |
|
203 (redirects.getCreateRedirect(program_entity, {'url_name': 'org_app'}), |
|
204 "Apply to become an Organization", 'any_access')] |
|
205 |
|
206 return items |
|
207 |
|
208 |
193 view = View() |
209 view = View() |
194 |
210 |
195 create = view.create |
211 create = view.create |
196 delete = view.delete |
212 delete = view.delete |
197 edit = view.edit |
213 edit = view.edit |