mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-07 05:43:11 +03:00
Clean code
This commit is contained in:
parent
af4bb53415
commit
1faa41c63c
|
@ -34,7 +34,6 @@ def connection_require_permission(permissions):
|
||||||
cls, resolver, connection, default_manager, max_limit,
|
cls, resolver, connection, default_manager, max_limit,
|
||||||
enforce_first_or_last, root, info, **args):
|
enforce_first_or_last, root, info, **args):
|
||||||
if has_perm(permissions=permissions, context=info.context):
|
if has_perm(permissions=permissions, context=info.context):
|
||||||
print("Has Perms")
|
|
||||||
return func(
|
return func(
|
||||||
cls, resolver, connection, default_manager, max_limit,
|
cls, resolver, connection, default_manager, max_limit,
|
||||||
enforce_first_or_last, root, info, **args)
|
enforce_first_or_last, root, info, **args)
|
||||||
|
|
|
@ -37,11 +37,8 @@ class MockUserContext(object):
|
||||||
return self.authenticated
|
return self.authenticated
|
||||||
|
|
||||||
def has_perm(self, check_perms):
|
def has_perm(self, check_perms):
|
||||||
print(self.username, self.perms)
|
|
||||||
if check_perms not in self.perms:
|
if check_perms not in self.perms:
|
||||||
print("NO PERMS")
|
|
||||||
return False
|
return False
|
||||||
print("HAS PERMS")
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,7 +142,7 @@ def test_node_anonymous_user():
|
||||||
def get_node(cls, info, id):
|
def get_node(cls, info, id):
|
||||||
return super(ReporterType, cls).get_node(info, id)
|
return super(ReporterType, cls).get_node(info, id)
|
||||||
|
|
||||||
r = Reporter.objects.create(
|
Reporter.objects.create(
|
||||||
first_name='John',
|
first_name='John',
|
||||||
last_name='Doe',
|
last_name='Doe',
|
||||||
email='johndoe@example.com',
|
email='johndoe@example.com',
|
||||||
|
@ -184,7 +181,7 @@ def test_node_no_context():
|
||||||
def get_node(cls, info, id):
|
def get_node(cls, info, id):
|
||||||
return super(ReporterType, cls).get_node(info, id)
|
return super(ReporterType, cls).get_node(info, id)
|
||||||
|
|
||||||
r = Reporter.objects.create(
|
Reporter.objects.create(
|
||||||
first_name='John',
|
first_name='John',
|
||||||
last_name='Doe',
|
last_name='Doe',
|
||||||
email='johndoe@example.com',
|
email='johndoe@example.com',
|
||||||
|
@ -221,7 +218,7 @@ def test_node_authenticated_user_no_permissions():
|
||||||
def get_node(cls, info, id):
|
def get_node(cls, info, id):
|
||||||
return super(ReporterType, cls).get_node(info, id)
|
return super(ReporterType, cls).get_node(info, id)
|
||||||
|
|
||||||
r = Reporter.objects.create(
|
Reporter.objects.create(
|
||||||
first_name='John',
|
first_name='John',
|
||||||
last_name='Doe',
|
last_name='Doe',
|
||||||
email='johndoe@example.com',
|
email='johndoe@example.com',
|
||||||
|
@ -260,7 +257,7 @@ def test_node_authenticated_user_with_permissions():
|
||||||
def get_node(cls, info, id):
|
def get_node(cls, info, id):
|
||||||
return super(ReporterType, cls).get_node(info, id)
|
return super(ReporterType, cls).get_node(info, id)
|
||||||
|
|
||||||
r = Reporter.objects.create(
|
Reporter.objects.create(
|
||||||
first_name='John',
|
first_name='John',
|
||||||
last_name='Doe',
|
last_name='Doe',
|
||||||
email='johndoe@example.com',
|
email='johndoe@example.com',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user