Example Visibility server side filtering

This commit is contained in:
Pawel Kowalski 2018-09-13 11:44:31 +02:00
parent 2ead4f221b
commit 2ad89ce6ef
3 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,19 @@
query ContentBlockQuery {
chapters {
edges {
node {
id
slug
contentBlocks(userGroups: ["EE18B"]) {
edges {
node {
id
title
slug
}
}
}
}
}
}
}

View File

@ -150,7 +150,8 @@ class AddContentBlock(relay.ClientIDMutation):
try: try:
parent = args.get('parent', None) parent = args.get('parent', None)
after = args.get('after', None) after = args.get('after', None)
new_content_block = cls.create_content_block(content_block_data=args.get('content_block'), parent=parent, new_content_block = cls.create_content_block(content_block_data=args.get('content_block'),
parent=parent,
after=after) after=after)
return cls(new_content_block=new_content_block) return cls(new_content_block=new_content_block)

View File

@ -29,7 +29,7 @@ class FilteredChapterNode(DjangoObjectType):
reduced = [] reduced = []
for user_group in user_groups: for user_group in user_groups:
content_blocks = ContentBlock.get_by_parent(self).exclude( content_blocks = ContentBlock.get_by_parent(self).exclude(
Q(visibility__user_group__name=user_group) Q(visible_to__user_group__name=user_group)
) )
reduced = chain(reduced, content_blocks) reduced = chain(reduced, content_blocks)