408 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
408 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
409 'role': 'a Site Developer '} |
409 'role': 'a Site Developer '} |
410 |
410 |
411 raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
411 raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
412 |
412 |
|
413 @allowDeveloper |
|
414 @denySidebar |
|
415 def checkIsGroupActive(self, django_args, group_logic): |
|
416 """Raises an alternate HTTP response if Group state is not active. |
|
417 |
|
418 Args: |
|
419 django_args: a dictionary with django's arguments |
|
420 |
|
421 Raises: |
|
422 AccessViolationResponse: |
|
423 * if no Group is found |
|
424 * if the Group state is not active |
|
425 """ |
|
426 |
|
427 fields = {'link_id': django_args['link_id']} |
|
428 |
|
429 if django_args.get('scope_path'): |
|
430 fields['scope_path'] = django_args['scope_path'] |
|
431 |
|
432 group_entity = group_logic.logic.getFromFieldsOr404(**fields) |
|
433 |
|
434 if group_entity.state == 'active': |
|
435 return |
|
436 |
|
437 # TODO tell the user that this group is not active |
|
438 self.deny(django_args) |
|
439 |
|
440 |
413 def checkCanMakeRequestToGroup(self, django_args, group_logic): |
441 def checkCanMakeRequestToGroup(self, django_args, group_logic): |
414 """Raises an alternate HTTP response if the specified group is not in an |
442 """Raises an alternate HTTP response if the specified group is not in an |
415 active state. |
443 active state. |
416 |
444 |
417 Note that state hasn't been implemented yet |
445 Note that state hasn't been implemented yet |
424 group_logic.logic, django_args['scope_path']) |
452 group_logic.logic, django_args['scope_path']) |
425 |
453 |
426 if not group_entity: |
454 if not group_entity: |
427 raise out_of_band.Error(DEF_GROUP_NOT_FOUND_MSG, status=404) |
455 raise out_of_band.Error(DEF_GROUP_NOT_FOUND_MSG, status=404) |
428 |
456 |
429 # TODO(ljvderijk) check if the group is active |
457 if group_entity.state != 'active': |
|
458 # TODO tell the user that this group is not active |
|
459 self.deny(django_args) |
|
460 |
430 return |
461 return |
431 |
462 |
432 def checkCanCreateFromRequest(self, django_args, role_name): |
463 def checkCanCreateFromRequest(self, django_args, role_name): |
433 """Raises an alternate HTTP response if the specified request does not exist |
464 """Raises an alternate HTTP response if the specified request does not exist |
434 or if it's state is not group_accepted. |
465 or if it's state is not group_accepted. Also when the group this request |
|
466 is from is in an inactive or invalid state access will be denied. |
435 """ |
467 """ |
436 |
468 |
437 self.checkIsUser(django_args) |
469 self.checkIsUser(django_args) |
438 |
470 |
439 user_entity = user_logic.getForCurrentAccount() |
471 user_entity = user_logic.getForCurrentAccount() |
449 |
481 |
450 if request_entity.state != 'group_accepted': |
482 if request_entity.state != 'group_accepted': |
451 # TODO tell the user that this request has not been accepted yet |
483 # TODO tell the user that this request has not been accepted yet |
452 self.deny(django_args) |
484 self.deny(django_args) |
453 |
485 |
|
486 if request_entity.scope.state in ['invalid', 'inactive']: |
|
487 # TODO tell the user that it is not possible to create this role anymore |
|
488 self.deny(django_args) |
|
489 |
454 return |
490 return |
455 |
491 |
456 def checkCanProcessRequest(self, django_args, role_name): |
492 def checkCanProcessRequest(self, django_args, role_name): |
457 """Raises an alternate HTTP response if the specified request does not exist |
493 """Raises an alternate HTTP response if the specified request does not exist |
458 or if it's state is completed or denied. |
494 or if it's state is completed or denied. Also Raises an alternate HTTP response |
|
495 whenever the group in the request is not active. |
459 """ |
496 """ |
460 |
497 |
461 fields = {'link_id': django_args['link_id'], |
498 fields = {'link_id': django_args['link_id'], |
462 'scope_path': django_args['scope_path'], |
499 'scope_path': django_args['scope_path'], |
463 'role': role_name} |
500 'role': role_name} |
464 |
501 |
465 request_entity = request_logic.getFromFieldsOr404(**fields) |
502 request_entity = request_logic.getFromFieldsOr404(**fields) |
466 |
503 |
467 if request_entity.state in ['completed', 'denied']: |
504 if request_entity.state in ['completed', 'denied']: |
468 # TODO tell the user that this request has been processed |
505 # TODO tell the user that this request has been processed |
|
506 self.deny(django_args) |
|
507 |
|
508 if request_entity.scope.state != 'active': |
|
509 # TODO tell the user that this group cannot process requests |
469 self.deny(django_args) |
510 self.deny(django_args) |
470 |
511 |
471 return |
512 return |
472 |
513 |
473 def checkIsMyGroupAcceptedRequest(self, django_args): |
514 def checkIsMyGroupAcceptedRequest(self, django_args): |