app/soc/views/helper/access.py
changeset 3032 f3886d1b00a5
parent 3029 3c09b9396e2e
child 3053 1dc307cb97d0
equal deleted inserted replaced
3031:7678f72140e6 3032:f3886d1b00a5
   820     django_args['scope_path'] = django_args['link_id']
   820     django_args['scope_path'] = django_args['link_id']
   821     return self._checkHasActiveRoleFor(django_args, logic, 'scope_path')
   821     return self._checkHasActiveRoleFor(django_args, logic, 'scope_path')
   822 
   822 
   823   def checkHasDocumentAccess(self, django_args, logic, target_scope):
   823   def checkHasDocumentAccess(self, django_args, logic, target_scope):
   824     """Checks that the user has access to the specified document scope.
   824     """Checks that the user has access to the specified document scope.
   825     
   825 
   826     Args:
   826     Args:
   827       django_args: a dictionary with django's arguments
   827       django_args: a dictionary with django's arguments
   828       logic: the logic that should be used to look up the entity
   828       logic: the logic that should be used to look up the entity
   829     """
   829     """
   830     
   830 
   831     prefix = django_args['prefix']
   831     prefix = django_args['prefix']
   832     if self.SCOPE_DEPTH.get(prefix):
   832     if self.SCOPE_DEPTH.get(prefix):
   833       scope_logic, depths = self.SCOPE_DEPTH[prefix]
   833       scope_logic, depths = self.SCOPE_DEPTH[prefix]
   834     else:
   834     else:
   835       return self.checkHasActiveRole(django_args, logic)
   835       return self.checkHasActiveRole(django_args, logic)
   868     """Raises an alternate HTTP response if the specified group is not in an
   868     """Raises an alternate HTTP response if the specified group is not in an
   869     active status.
   869     active status.
   870 
   870 
   871     Args:
   871     Args:
   872       django_args: a dictionary with django's arguments
   872       django_args: a dictionary with django's arguments
   873       group_logic: Logic module for the type of group which the request is for
   873       group_logic: Logic instance for the group which the request is for
   874     """
   874     """
   875 
   875 
   876     self.checkIsUser(django_args)
   876     self.checkIsUser(django_args)
   877 
   877 
   878     group_entity = role_logic.getGroupEntityFromScopePath(
   878     group_entity = group_logic.getFromKeyName(django_args['scope_path'])
   879         group_logic.logic, django_args['scope_path'])
       
   880 
   879 
   881     if not group_entity:
   880     if not group_entity:
   882       raise out_of_band.Error(DEF_GROUP_NOT_FOUND_MSG, status=404)
   881       raise out_of_band.Error(DEF_GROUP_NOT_FOUND_MSG, status=404)
   883 
   882 
   884     if group_entity.status != 'active':
   883     if group_entity.status != 'active':
   889 
   888 
   890   def checkCanCreateFromRequest(self, django_args, role_name):
   889   def checkCanCreateFromRequest(self, django_args, role_name):
   891     """Raises an alternate HTTP response if the specified request does not exist
   890     """Raises an alternate HTTP response if the specified request does not exist
   892        or if it's status is not group_accepted. Also when the group this request
   891        or if it's status is not group_accepted. Also when the group this request
   893        is from is in an inactive or invalid status access will be denied.
   892        is from is in an inactive or invalid status access will be denied.
   894     
   893 
   895     Args:
   894     Args:
   896       django_args: a dictionary with django's arguments
   895       django_args: a dictionary with django's arguments
   897       role_name: name of the role
   896       role_name: name of the role
   898     """
   897     """
   899 
   898