40 from soc.views.models.request import view as request_view |
40 from soc.views.models.request import view as request_view |
41 from soc.views.sitemap import sidebar |
41 from soc.views.sitemap import sidebar |
42 |
42 |
43 import soc.views.helper |
43 import soc.views.helper |
44 |
44 |
|
45 |
45 class View(presence.View): |
46 class View(presence.View): |
46 """View methods for the Group model. |
47 """View methods for the Group model. |
47 """ |
48 """ |
48 |
49 |
49 |
50 |
103 'clean_shipping_state': cleaning.clean_ascii_only('shipping_state'), |
104 'clean_shipping_state': cleaning.clean_ascii_only('shipping_state'), |
104 'clean_shipping_postalcode': cleaning.clean_ascii_only( |
105 'clean_shipping_postalcode': cleaning.clean_ascii_only( |
105 'shipping_postalcode'), |
106 'shipping_postalcode'), |
106 } |
107 } |
107 |
108 |
108 |
|
109 new_params['role_views'] = {} |
109 new_params['role_views'] = {} |
110 |
110 |
111 params = dicts.merge(params, new_params, sub_merge=True) |
111 params = dicts.merge(params, new_params, sub_merge=True) |
112 |
112 |
113 super(View, self).__init__(params=params) |
113 super(View, self).__init__(params=params) |
128 # only if we are creating a new entity we should fill in founder |
128 # only if we are creating a new entity we should fill in founder |
129 user = user_logic.logic.getForCurrentAccount() |
129 user = user_logic.logic.getForCurrentAccount() |
130 fields['founder'] = user |
130 fields['founder'] = user |
131 |
131 |
132 super(View, self)._editPost(request, entity, fields) |
132 super(View, self)._editPost(request, entity, fields) |
133 |
|
134 |
133 |
135 @decorators.merge_params |
134 @decorators.merge_params |
136 @decorators.check_access |
135 @decorators.check_access |
137 def applicant(self, request, access_type, |
136 def applicant(self, request, access_type, |
138 page_name=None, params=None, **kwargs): |
137 page_name=None, params=None, **kwargs): |
240 |
239 |
241 scope = self._params['scope_logic'].logic.getFromKeyName( |
240 scope = self._params['scope_logic'].logic.getFromKeyName( |
242 fields['scope_path']) |
241 fields['scope_path']) |
243 fields['scope'] = scope |
242 fields['scope'] = scope |
244 |
243 |
245 |
|
246 @decorators.merge_params |
244 @decorators.merge_params |
247 @decorators.check_access |
245 @decorators.check_access |
248 def listRequests(self, request, access_type, |
246 def listRequests(self, request, access_type, |
249 page_name=None, params=None, **kwargs): |
247 page_name=None, params=None, **kwargs): |
250 """Gives an overview of all the requests for a specific group. |
248 """Gives an overview of all the requests for a specific group. |
264 group_logic = params['logic'] |
262 group_logic = params['logic'] |
265 |
263 |
266 group_entity = group_logic.getFromKeyFields(kwargs) |
264 group_entity = group_logic.getFromKeyFields(kwargs) |
267 |
265 |
268 role_names = params['role_views'].keys() |
266 role_names = params['role_views'].keys() |
269 |
267 |
270 # list all incoming requests |
268 # list all incoming requests |
271 filter = { |
269 filter = { |
272 'scope': group_entity, |
270 'scope': group_entity, |
273 'role': role_names, |
271 'role': role_names, |
274 'status': 'new' |
272 'status': 'new' |
279 |
277 |
280 # define the list redirect action to the request processing page |
278 # define the list redirect action to the request processing page |
281 inc_req_params['list_action'] = (redirects.getProcessRequestRedirect, None) |
279 inc_req_params['list_action'] = (redirects.getProcessRequestRedirect, None) |
282 inc_req_params['list_description'] = ugettext( |
280 inc_req_params['list_description'] = ugettext( |
283 "An overview of the %(name)s's incoming requests." % params) |
281 "An overview of the %(name)s's incoming requests." % params) |
284 |
282 |
285 inc_req_content = list_helper.getListContent( |
283 inc_req_content = list_helper.getListContent( |
286 request, inc_req_params, filter, idx=0) |
284 request, inc_req_params, filter, idx=0) |
287 |
285 |
288 # list all outstanding invites |
286 # list all outstanding invites |
289 filter = { |
287 filter = { |
315 |
313 |
316 # define the list redirect action to the request processing page |
314 # define the list redirect action to the request processing page |
317 ignored_params['list_action'] = (redirects.getProcessRequestRedirect, None) |
315 ignored_params['list_action'] = (redirects.getProcessRequestRedirect, None) |
318 ignored_params['list_description'] = ugettext( |
316 ignored_params['list_description'] = ugettext( |
319 "An overview of the %(name)s's ignored requests." % params) |
317 "An overview of the %(name)s's ignored requests." % params) |
320 |
318 |
321 ignored_content = list_helper.getListContent( |
319 ignored_content = list_helper.getListContent( |
322 request, ignored_params, filter, idx=2) |
320 request, ignored_params, filter, idx=2) |
323 |
321 |
324 contents = [inc_req_content, out_inv_content, ignored_content] |
322 contents = [inc_req_content, out_inv_content, ignored_content] |
325 |
323 |
326 return self._list(request, params, contents, page_name) |
324 return self._list(request, params, contents, page_name) |
327 |
|
328 |
325 |
329 @decorators.merge_params |
326 @decorators.merge_params |
330 @decorators.check_access |
327 @decorators.check_access |
331 def listRoles(self, request, access_type, |
328 def listRoles(self, request, access_type, |
332 page_name=None, params=None, **kwargs): |
329 page_name=None, params=None, **kwargs): |
365 |
362 |
366 list_params['list_action'] = (redirects.getManageRedirect, list_params) |
363 list_params['list_action'] = (redirects.getManageRedirect, list_params) |
367 list_params['list_description'] = ugettext( |
364 list_params['list_description'] = ugettext( |
368 "An overview of the %s for this %s." % ( |
365 "An overview of the %s for this %s." % ( |
369 list_params['name_plural'], params['name'])) |
366 list_params['name_plural'], params['name'])) |
370 |
367 |
371 new_list_content = list_helper.getListContent( |
368 new_list_content = list_helper.getListContent( |
372 request, list_params, filter, idx=index) |
369 request, list_params, filter, idx=index) |
373 |
370 |
374 contents += [new_list_content] |
371 contents += [new_list_content] |
375 |
372 |
378 # call the _list method from base.View to show the list |
375 # call the _list method from base.View to show the list |
379 return self._list(request, params, contents, page_name) |
376 return self._list(request, params, contents, page_name) |
380 |
377 |
381 def registerRole(self, role_name, role_view): |
378 def registerRole(self, role_name, role_view): |
382 """Adds a role to the role_views param. |
379 """Adds a role to the role_views param. |
383 |
380 |
384 Args: |
381 Args: |
385 role_name: The name of the role that needs to be added |
382 role_name: The name of the role that needs to be added |
386 role_view: The view that needs to be added to role_views. |
383 role_view: The view that needs to be added to role_views. |
387 """ |
384 """ |
388 |
385 |