639 """ |
639 """ |
640 |
640 |
641 django_args['user'] = self.user |
641 django_args['user'] = self.user |
642 self.checkIsActive(django_args, logic, field_name, 'user') |
642 self.checkIsActive(django_args, logic, field_name, 'user') |
643 |
643 |
|
644 def checkHasDocumentAccess(self, django_args, logic, target_scope): |
|
645 """Checks that the user has access to the specified document scope. |
|
646 """ |
|
647 |
|
648 prefix = django_args['prefix'] |
|
649 scope_logic, depths = self.SCOPE_DEPTH.get(prefix, (None, {})) |
|
650 depth = depths.get(target_scope, 0) |
|
651 |
|
652 # nothing to do |
|
653 if not (scope_logic and depth): |
|
654 return self.checkHasActiveRoleForScope(django_args, logic) |
|
655 |
|
656 # we don't want to modify the original django args |
|
657 django_args = django_args.copy() |
|
658 |
|
659 entity = scope_logic.getFromKeyName(django_args['scope_path']) |
|
660 |
|
661 # cannot have access to the specified scope if it is invalid |
|
662 if not entity: |
|
663 raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_ENTITY_MSG) |
|
664 |
|
665 # walk up the scope to where we need to be |
|
666 for _ in range(depth): |
|
667 entity = entity.scope |
|
668 |
|
669 django_args['scope_path'] = entity.key().name() |
|
670 |
|
671 self.checkHasActiveRoleForScope(django_args, logic) |
|
672 |
644 def checkSeeded(self, django_args, checker_name, *args): |
673 def checkSeeded(self, django_args, checker_name, *args): |
645 """Wrapper to update the django_args with the contens of seed first. |
674 """Wrapper to update the django_args with the contens of seed first. |
646 """ |
675 """ |
647 |
676 |
648 django_args.update(django_args.get('seed', {})) |
677 django_args.update(django_args.get('seed', {})) |