131 |
139 |
132 |
140 |
133 @decorators.merge_params |
141 @decorators.merge_params |
134 @decorators.check_access |
142 @decorators.check_access |
135 def list(self, request, access_type, |
143 def list(self, request, access_type, |
136 page_name=None, params=None, filter=None): |
144 page_name=None, params=None, filter={}, **kwargs): |
137 """Lists all notifications that the current logged in user has stored. |
145 """Lists all notifications in seperate tables, depending on their status. |
138 |
146 |
139 for parameters see base.list() |
147 for parameters see base.list() |
140 """ |
148 """ |
141 |
149 |
142 # get the current user |
150 # create the selection list |
143 user_entity = user_logic.logic.getForCurrentAccount() |
151 selection=[('needs review',(redirects.getEditRedirect, params)), |
144 |
152 ('pre-accepted', (redirects.getEditRedirect, params)), |
145 is_developer = accounts.isDeveloper(user=user_entity) |
153 ('accepted', (redirects.getEditRedirect, params)), |
|
154 ('rejected', (redirects.getEditRedirect, params)), |
|
155 ('ignored', (redirects.getEditRedirect, params)),] |
|
156 |
|
157 return self._applicationListConstructor(request, params, page_name, |
|
158 filter=filter, selection=selection, **kwargs) |
|
159 |
|
160 |
|
161 def _applicationListConstructor(self, request, params, page_name, filter={}, |
|
162 selection=[], **kwargs): |
|
163 """Constructs the list containing applications for the given the arguments. |
|
164 |
|
165 Args: |
|
166 filter: This is the filter used for all application |
|
167 selection: This is a list containing tuples stating the status for an |
|
168 application and the redirect action. |
|
169 See base.View.public() for the rest. |
|
170 |
|
171 Returns: |
|
172 HTTP Response containing the list view. |
|
173 |
|
174 """ |
|
175 |
146 contents = [] |
176 contents = [] |
147 |
177 list_params = params.copy() |
148 filter = { |
178 index = 0 |
149 'status': 'needs review', |
179 |
150 } |
180 for choice in selection: |
151 |
181 # only select the requests that have been pre-accpeted |
152 if not is_developer: |
182 filter['status'] = choice[0] |
153 # only select the applications for this user so construct a filter |
183 |
154 filter['applicant'] = user_entity |
184 list_params['list_description'] = ( |
155 |
185 DEF_APPLICATION_LIST_DESCRIPTION_FMT % ( |
156 # get all the pending applications |
186 {'name_plural': params['name_plural'], 'status': choice[0]})) |
157 |
187 list_params['list_action'] = choice[1] |
158 pa_params = params.copy() # pending applications |
188 |
159 |
189 list_content = list_helper.getListContent( |
160 if is_developer: |
190 request, list_params, filter, index) |
161 pa_params['list_description'] = ugettext( |
191 |
162 "An overview of all pending %(name_plural)s.") % params |
192 contents += [list_content] |
163 else: |
193 |
164 pa_params['list_description'] = ugettext( |
194 index += 1 |
165 "An overview of your pending %(name_plural)s.") % params |
|
166 |
|
167 pa_list = list_helper.getListContent( |
|
168 request, pa_params, filter, 0) |
|
169 |
|
170 # get all the reviewed applications now |
|
171 |
|
172 # re-use the old filter, but set to only reviewed and accepted |
|
173 filter['status'] = 'accepted' |
|
174 |
|
175 aa_params = params.copy() # accepted applications |
|
176 |
|
177 if is_developer: |
|
178 aa_params['list_description'] = ugettext( |
|
179 "An overview of all accepted %(name_plural)s.") % params |
|
180 else: |
|
181 aa_params['list_description'] = ugettext( |
|
182 "An overview of your accepted %(name_plural)s.") % params |
|
183 |
|
184 aa_params['url_name'] = params['group_url_name'] |
|
185 aa_params['list_action'] = (redirects.getApplicantRedirect, aa_params) |
|
186 |
|
187 aa_list = list_helper.getListContent( |
|
188 request, aa_params, filter, 1) |
|
189 |
|
190 if is_developer: |
|
191 # re use the old filter, but this time only for pre-accepted apps |
|
192 filter['status'] = 'pre-accepted' |
|
193 |
|
194 pa_params = params.copy() # pre-accepted applications |
|
195 |
|
196 pa_params['list_description'] = ugettext( |
|
197 "An overview of all pre-accepted %(name_plural)s.") % params |
|
198 |
|
199 pa_list = list_helper.getListContent( |
|
200 request, pa_params, filter, 4) |
|
201 |
|
202 contents += [pa_list] |
|
203 |
|
204 # get all the reviewed applications that were denied |
|
205 |
|
206 # re use the old filter, but this time only for denied apps |
|
207 filter['status'] = 'rejected' |
|
208 |
|
209 da_params = params.copy() # denied applications |
|
210 |
|
211 if is_developer: |
|
212 da_params['list_description'] = ugettext( |
|
213 "An overview of all denied %(name_plural)s.") % params |
|
214 else: |
|
215 da_params['list_description'] = ugettext( |
|
216 "An overview of your denied %(name_plural)s.") % params |
|
217 |
|
218 da_list = list_helper.getListContent( |
|
219 request, da_params, filter, 2) |
|
220 |
|
221 contents += [pa_list, aa_list, da_list] |
|
222 |
|
223 if is_developer: |
|
224 # re use the old filter, but this time only for ignored apps |
|
225 filter['status'] = 'ignored' |
|
226 |
|
227 ia_params = params.copy() # ignored applications |
|
228 |
|
229 ia_params['list_description'] = ugettext( |
|
230 "An overview of all ignored %(name_plural)s.") % params |
|
231 |
|
232 ia_list = list_helper.getListContent( |
|
233 request, ia_params, filter, 3) |
|
234 |
|
235 contents += [ia_list] |
|
236 |
195 |
237 # call the _list method from base to display the list |
196 # call the _list method from base to display the list |
238 return self._list(request, params, contents, page_name) |
197 return self._list(request, params, contents, page_name) |
239 |
198 |
|
199 |
|
200 @decorators.merge_params |
|
201 @decorators.check_access |
|
202 def listSelf(self, request, access_type, |
|
203 page_name=None, params=None, **kwargs): |
|
204 """List all applications from the current logged-in user. |
|
205 |
|
206 For params see base.View.public(). |
|
207 """ |
|
208 |
|
209 user_entity = user_logic.logic.getForCurrentAccount() |
|
210 filter = {'applicant' : user_entity} |
|
211 |
|
212 if kwargs['scope_path']: |
|
213 filter['scope_path'] = kwargs['scope_path'] |
|
214 |
|
215 # create the selection list |
|
216 selection=[('needs review',(redirects.getEditRedirect, params)), |
|
217 ('accepted', (redirects.getApplicantRedirect, |
|
218 {'url_name': params['group_url_name']})), |
|
219 ('rejected', (redirects.getEditRedirect, params))] |
|
220 |
|
221 return self._applicationListConstructor(request, params, page_name, |
|
222 filter=filter, selection=selection, **kwargs) |
240 |
223 |
241 @decorators.merge_params |
224 @decorators.merge_params |
242 @decorators.check_access |
225 @decorators.check_access |
243 def review(self, request, access_type, |
226 def review(self, request, access_type, |
244 page_name=None, params=None, **kwargs): |
227 page_name=None, params=None, **kwargs): |
298 page_name=None, params=None, **kwargs): |
292 page_name=None, params=None, **kwargs): |
299 """Displays multiple lists of applications that are in a different |
293 """Displays multiple lists of applications that are in a different |
300 status of the application process. |
294 status of the application process. |
301 """ |
295 """ |
302 |
296 |
303 params = dicts.merge(params, self._params) |
297 selection = [('needs review',(redirects.getReviewRedirect, params)), |
|
298 ('accepted', (redirects.getReviewRedirect, params)), |
|
299 ('pre-accepted', (redirects.getReviewRedirect, params)), |
|
300 ('rejected', (redirects.getReviewRedirect, params)), |
|
301 ('ignored', (redirects.getReviewRedirect, params)),] |
304 |
302 |
305 filter = {} |
303 filter = {} |
306 |
304 |
307 if kwargs.get('scope_path'): |
305 if kwargs['scope_path']: |
308 filter['scope_path'] = kwargs['scope_path'] |
306 filter['scope_path'] = kwargs['scope_path'] |
309 elif kwargs.get('link_id'): |
307 |
310 filter['scope_path'] = kwargs['link_id'] |
308 return self._applicationListConstructor(request, params, page_name, |
311 |
309 filter=filter, selection=selection, **kwargs) |
312 # only select the requests that haven't been reviewed yet |
310 |
313 filter['status'] = 'needs review' |
|
314 |
|
315 ur_params = params.copy() |
|
316 ur_params['list_description'] = ugettext('A list of all unhandled ' |
|
317 '%(name_plural)s.') % params |
|
318 ur_params ['list_action'] = (redirects.getReviewRedirect, params) |
|
319 |
|
320 ur_list = list_helper.getListContent( |
|
321 request, ur_params, filter, 0) |
|
322 |
|
323 # only select the requests that haven't been turned into a group yet |
|
324 filter['status'] = 'accepted' |
|
325 |
|
326 uh_params = params.copy() |
|
327 uh_params['list_description'] = ugettext('A list of all %(name_plural)s ' |
|
328 'that have been accepted but not completed yet') % params |
|
329 uh_params ['list_action'] = (redirects.getReviewRedirect, params) |
|
330 |
|
331 uh_list = list_helper.getListContent( |
|
332 request, uh_params, filter, 1) |
|
333 |
|
334 # only select the requests that have been pre-accpeted |
|
335 filter['status'] = 'pre-accepted' |
|
336 |
|
337 pa_params = params.copy() |
|
338 pa_params['list_description'] = ugettext( |
|
339 "An overview of all pre-accepted %(name_plural)s.") % params |
|
340 pa_params ['list_action'] = (redirects.getReviewRedirect, params) |
|
341 |
|
342 pa_list = list_helper.getListContent( |
|
343 request, pa_params, filter, 4) |
|
344 |
|
345 # only select the requests the have been rejected |
|
346 filter ['status'] = 'rejected' |
|
347 |
|
348 den_params = params.copy() |
|
349 den_params['list_description'] = ugettext('A list of all %(name_plural)s ' |
|
350 'that have been rejected') % params |
|
351 den_params ['list_action'] = (redirects.getReviewRedirect, params) |
|
352 |
|
353 den_list = list_helper.getListContent( |
|
354 request, den_params, filter, 2) |
|
355 |
|
356 # only select the request that have been ignored |
|
357 filter ['status'] = 'ignored' |
|
358 |
|
359 ign_params = params.copy() |
|
360 ign_params['list_description'] = ugettext('A list of all %(name_plural)s ' |
|
361 'that have been ignored') % params |
|
362 ign_params ['list_action'] = (redirects.getReviewRedirect, params) |
|
363 |
|
364 ign_list = list_helper.getListContent( |
|
365 request, ign_params, filter, 3) |
|
366 |
|
367 # fill contents with all the needed lists |
|
368 contents = [ur_list, uh_list, pa_list, den_list, ign_list] |
|
369 |
|
370 # call the _list method from base to display the list |
|
371 return self._list(request, params, contents, page_name) |
|
372 |
|