def scoped_groups(self, authority, document_uri): """ Return scoped groups for the URI and authority Only open and restricted groups are "supposed" to have scope, but technically this query is agnostic to the group's type—it will return any group who has a scope that matches the document_uri's scope. Note: If private groups are ever allowed to be scoped, this needs attention. :param authority: Filter groups by this authority :type authority: string :arg document_uri: Use this URI to find groups with matching scopes :type document_uri: string :rtype: list of :class:`h.models.group` """ origin = scope_util.uri_scope(document_uri) if not origin: return [] groups = (self._session.query(models.GroupScope, models.Group).filter( models.Group.id == models.GroupScope.group_id).filter( models.GroupScope.origin == origin).filter( models.Group.authority == authority).all()) scoped_groups = [group for groupscope, group in groups] return self._sort(scoped_groups)
def _scoped_groups(self, authority, document_uri): """ Return scoped groups for the URI and authority Only open and restricted groups are "supposed" to have scope, but technically this query is agnostic to the group's type—it will return any group who has a scope that matches the document_uri's scope. Note: If private groups are ever allowed to be scoped, this needs attention. """ origin = scope_util.uri_scope(document_uri) if not origin: return [] groups = (self._session.query(models.GroupScope, models.Group) .filter(models.Group.id == models.GroupScope.group_id) .filter(models.GroupScope.origin == origin) .filter(models.Group.authority == authority) .all()) scoped_groups = [group for groupscope, group in groups] return self._sort(scoped_groups)
def test_it_parses_scope_from_uri(uri, expected_scope): scope = scope_util.uri_scope(uri) assert scope == expected_scope