90 'Accept invite for %(name)s'), |
90 'Accept invite for %(name)s'), |
91 (r'^%(url_name)s/(?P<access_type>process_request)/%(scope)s/%(lnp)s$', |
91 (r'^%(url_name)s/(?P<access_type>process_request)/%(scope)s/%(lnp)s$', |
92 'soc.views.models.%(module_name)s.process_request', |
92 'soc.views.models.%(module_name)s.process_request', |
93 'Process request for %(name)s')] |
93 'Process request for %(name)s')] |
94 |
94 |
|
95 # add manage pattern |
|
96 patterns += [(r'^%(url_name)s/(?P<access_type>manage)/%(scope)s/%(lnp)s$', |
|
97 'soc.views.models.%(module_name)s.manage', |
|
98 'Manage a %(name)s'),] |
|
99 |
95 new_params['extra_django_patterns'] = patterns |
100 new_params['extra_django_patterns'] = patterns |
96 new_params['scope_redirect'] = redirects.getInviteRedirect |
101 new_params['scope_redirect'] = redirects.getInviteRedirect |
97 |
102 |
98 params = dicts.merge(params, new_params) |
103 params = dicts.merge(params, new_params) |
99 |
104 |
100 super(View, self).__init__(params=params) |
105 super(View, self).__init__(params=params) |
|
106 |
|
107 # add manage template |
|
108 params['manage_template'] = 'soc/%(module_name)s/manage.html' % params |
101 |
109 |
102 @decorators.merge_params |
110 @decorators.merge_params |
103 @decorators.check_access |
111 @decorators.check_access |
104 def invite(self, request, access_type, |
112 def invite(self, request, access_type, |
105 page_name=None, params=None, **kwargs): |
113 page_name=None, params=None, **kwargs): |
323 pass |
331 pass |
324 |
332 |
325 |
333 |
326 @decorators.merge_params |
334 @decorators.merge_params |
327 @decorators.check_access |
335 @decorators.check_access |
|
336 def manage(self, request, access_type, |
|
337 page_name=None, params=None, **kwargs): |
|
338 """Handles the request concerning the view that let's |
|
339 you manage a role's state. |
|
340 |
|
341 Args: |
|
342 request: the standard Django HTTP request object |
|
343 page_name: the page name displayed in templates as page and header title |
|
344 params: a dict with params for this View |
|
345 kwargs: the Key Fields for the specified entity |
|
346 """ |
|
347 |
|
348 # get the context for this webpage |
|
349 context = responses.getUniversalContext(request) |
|
350 context['page_name'] = page_name |
|
351 |
|
352 logic = params['logic'] |
|
353 |
|
354 # get the entity for the given fields in kwargs |
|
355 fields = {'scope_path': kwargs['scope_path'], |
|
356 'link_id': kwargs['link_id']} |
|
357 role_entity = logic.getForFields(kwargs, unique=True) |
|
358 |
|
359 # get the redirect for the cancel button or when the resignation is done |
|
360 redirect = redirects.getListRolesRedirect(role_entity.scope, |
|
361 params['group_view'].getParams()) |
|
362 |
|
363 # check to see if resign is true |
|
364 get_dict = request.GET |
|
365 resign = get_dict.get('resign') |
|
366 |
|
367 if resign == 'true': |
|
368 # change the state of this role_entity to invalid |
|
369 fields = {'state': 'invalid'} |
|
370 logic.updateEntityProperties(role_entity, fields) |
|
371 |
|
372 # redirect to the roles listing |
|
373 return http.HttpResponseRedirect(redirect) |
|
374 |
|
375 # set the appropriate context |
|
376 context['entity'] = role_entity |
|
377 context['url_name'] = params['url_name'] |
|
378 context['cancel_redirect'] = redirect |
|
379 |
|
380 # get the manage template |
|
381 template = params['manage_template'] |
|
382 |
|
383 # return a proper response |
|
384 return responses.respond(request, template, context=context) |
|
385 |
|
386 |
|
387 @decorators.merge_params |
|
388 @decorators.check_access |
328 def request(self, request, access_type, |
389 def request(self, request, access_type, |
329 page_name=None, params=None, **kwargs): |
390 page_name=None, params=None, **kwargs): |
330 """Handles the GET request concerning the view that creates a request |
391 """Handles the request concerning the view that creates a request |
331 for attaining a certain Role. |
392 for attaining a certain Role. |
332 |
393 |
333 Args: |
394 Args: |
334 request: the standard Django HTTP request object |
395 request: the standard Django HTTP request object |
335 page_name: the page name displayed in templates as page and header title |
396 page_name: the page name displayed in templates as page and header title |