equal
deleted
inserted
replaced
207 params: a dict with params for this View |
207 params: a dict with params for this View |
208 kwargs: the Key Fields for the specified entity |
208 kwargs: the Key Fields for the specified entity |
209 """ |
209 """ |
210 |
210 |
211 # set the role to the right name |
211 # set the role to the right name |
212 fields = {'role': '%(module_name)s' % (params)} |
212 fields = {'role': params['logic'].role_name} |
213 |
213 |
214 # get the request view parameters and initialize the create form |
214 # get the request view parameters and initialize the create form |
215 request_params = request_view.view.getParams() |
215 request_params = request_view.view.getParams() |
216 form = request_params['invite_form'](initial=fields) |
216 form = request_params['invite_form'](initial=fields) |
217 |
217 |
251 |
251 |
252 # create the fields for the new request entity |
252 # create the fields for the new request entity |
253 request_fields = {'link_id': form_fields['link_id'].link_id, |
253 request_fields = {'link_id': form_fields['link_id'].link_id, |
254 'scope': group, |
254 'scope': group, |
255 'scope_path': request_scope_path, |
255 'scope_path': request_scope_path, |
256 'role': params['module_name'], |
256 'role': params['logic'].role_name, |
257 'role_verbose': params['name'], |
257 'role_verbose': params['name'], |
258 'status': 'group_accepted'} |
258 'status': 'group_accepted'} |
259 |
259 |
260 if not self._isValidNewRequest(request_fields, params): |
260 if not self._isValidNewRequest(request_fields, params): |
261 # not a valid invite |
261 # not a valid invite |
291 else: |
291 else: |
292 request_scope_path = group_entity.link_id |
292 request_scope_path = group_entity.link_id |
293 |
293 |
294 return request_scope_path |
294 return request_scope_path |
295 |
295 |
296 |
|
297 @decorators.merge_params |
296 @decorators.merge_params |
298 @decorators.check_access |
297 @decorators.check_access |
299 def acceptInvite(self, request, access_type, |
298 def acceptInvite(self, request, access_type, |
300 page_name=None, params=None, **kwargs): |
299 page_name=None, params=None, **kwargs): |
301 """Creates the page process an invite into a Role. |
300 """Creates the page process an invite into a Role. |
378 |
377 |
379 # create new Role entity |
378 # create new Role entity |
380 entity = self._logic.updateOrCreateFromKeyName(fields, key_name) |
379 entity = self._logic.updateOrCreateFromKeyName(fields, key_name) |
381 |
380 |
382 # mark the request as completed |
381 # mark the request as completed |
383 request_helper.completeRequestForRole(entity, params['module_name']) |
382 request_helper.completeRequestForRole(entity, params['logic'].role_name) |
384 |
383 |
385 # redirect to the roles overview page |
384 # redirect to the roles overview page |
386 return http.HttpResponseRedirect('/user/roles') |
385 return http.HttpResponseRedirect('/user/roles') |
387 |
386 |
388 def _acceptInvitePost(self, fields, request, context, params, **kwargs): |
387 def _acceptInvitePost(self, fields, request, context, params, **kwargs): |
394 context: dictionary containing the context for this view |
393 context: dictionary containing the context for this view |
395 params: a dict with params for this View |
394 params: a dict with params for this View |
396 kwargs: the Key Fields for the specified entity |
395 kwargs: the Key Fields for the specified entity |
397 """ |
396 """ |
398 pass |
397 pass |
399 |
|
400 |
398 |
401 @decorators.merge_params |
399 @decorators.merge_params |
402 @decorators.check_access |
400 @decorators.check_access |
403 def manage(self, request, access_type, |
401 def manage(self, request, access_type, |
404 page_name=None, params=None, **kwargs): |
402 page_name=None, params=None, **kwargs): |
498 |
496 |
499 # set right fields for the request form |
497 # set right fields for the request form |
500 user_entity = user_logic.logic.getForCurrentAccount() |
498 user_entity = user_logic.logic.getForCurrentAccount() |
501 # pylint: disable-msg=E1103 |
499 # pylint: disable-msg=E1103 |
502 fields = {'link_id' : user_entity.link_id, |
500 fields = {'link_id' : user_entity.link_id, |
503 'role' : params['module_name'], |
501 'role' : params['logic'].role_name, |
504 'group_id' : kwargs['scope_path']} |
502 'group_id' : kwargs['scope_path']} |
505 |
503 |
506 # get the request view parameters and initialize the create form |
504 # get the request view parameters and initialize the create form |
507 request_params = request_view.view.getParams() |
505 request_params = request_view.view.getParams() |
508 form = request_params['request_form'](initial=fields) |
506 form = request_params['request_form'](initial=fields) |
542 user_entity = user_logic.logic.getForCurrentAccount() |
540 user_entity = user_logic.logic.getForCurrentAccount() |
543 # pylint: disable-msg=E1103 |
541 # pylint: disable-msg=E1103 |
544 request_fields = {'link_id' : user_entity.link_id, |
542 request_fields = {'link_id' : user_entity.link_id, |
545 'scope' : group, |
543 'scope' : group, |
546 'scope_path' : request_scope_path, |
544 'scope_path' : request_scope_path, |
547 'role' : params['module_name'], |
545 'role' : params['logic'].role_name, |
548 'role_verbose' : params['name'], |
546 'role_verbose' : params['name'], |
549 'status' : 'new'} |
547 'status' : 'new'} |
550 |
548 |
551 if not self._isValidNewRequest(request_fields, params): |
549 if not self._isValidNewRequest(request_fields, params): |
552 # not a valid request |
550 # not a valid request |
564 # able to process this request |
562 # able to process this request |
565 |
563 |
566 # redirect to requests overview |
564 # redirect to requests overview |
567 return http.HttpResponseRedirect('/user/requests') |
565 return http.HttpResponseRedirect('/user/requests') |
568 |
566 |
569 |
|
570 @decorators.merge_params |
567 @decorators.merge_params |
571 @decorators.check_access |
568 @decorators.check_access |
572 def processRequest(self, request, access_type, |
569 def processRequest(self, request, access_type, |
573 page_name=None, params=None, **kwargs): |
570 page_name=None, params=None, **kwargs): |
574 """Creates the page upon which a request can be processed. |
571 """Creates the page upon which a request can be processed. |
587 context['page_name'] = page_name |
584 context['page_name'] = page_name |
588 |
585 |
589 # get the request entity using the information from kwargs |
586 # get the request entity using the information from kwargs |
590 fields = {'link_id': kwargs['link_id'], |
587 fields = {'link_id': kwargs['link_id'], |
591 'scope_path': kwargs['scope_path'], |
588 'scope_path': kwargs['scope_path'], |
592 'role': params['module_name']} |
589 'role': params['logic'].role_name} |
593 request_entity = request_logic.logic.getForFields(fields, unique=True) |
590 request_entity = request_logic.logic.getForFields(fields, unique=True) |
594 |
591 |
595 # pylint: disable-msg=E1103 |
592 # pylint: disable-msg=E1103 |
596 user_entity = user_logic.logic.getFromKeyNameOr404(request_entity.link_id) |
593 user_entity = user_logic.logic.getFromKeyNameOr404(request_entity.link_id) |
597 |
594 |
618 |
615 |
619 # put the entity in the context |
616 # put the entity in the context |
620 context['entity'] = request_entity |
617 context['entity'] = request_entity |
621 context['user_in_request'] = user_entity |
618 context['user_in_request'] = user_entity |
622 context['request_status'] = request_entity.status |
619 context['request_status'] = request_entity.status |
623 context['module_name'] = params['module_name'] |
620 context['role_name'] = params['logic'].role_name |
624 |
621 |
625 #display the request processing page using the appropriate template |
622 #display the request processing page using the appropriate template |
626 template = request_view.view.getParams()['request_processing_template'] |
623 template = request_view.view.getParams()['request_processing_template'] |
627 |
624 |
628 return responses.respond(request, template, context=context) |
625 return responses.respond(request, template, context=context) |