Fix incorrect module level mutation
This commit is contained in:
parent
e6dbe06ca9
commit
8e226e1187
|
|
@ -21,11 +21,14 @@ class UpdateSolutionVisibility(relay.ClientIDMutation):
|
|||
@classmethod
|
||||
def mutate_and_get_payload(cls, root, info, **args):
|
||||
try:
|
||||
slug = args.get('slug')
|
||||
enabled = args.get('enabled')
|
||||
slug = args.get("slug")
|
||||
enabled = args.get("enabled")
|
||||
user = info.context.user
|
||||
selected_class = user.selected_class
|
||||
if 'users.can_manage_school_class_content' not in user.get_role_permissions():
|
||||
if (
|
||||
"users.can_manage_school_class_content"
|
||||
not in user.get_role_permissions()
|
||||
):
|
||||
raise PermissionError()
|
||||
|
||||
module = Module.objects.get(slug=slug)
|
||||
|
|
@ -40,7 +43,7 @@ class UpdateSolutionVisibility(relay.ClientIDMutation):
|
|||
except PermissionError:
|
||||
errors = ["You don't have the permission to do that."]
|
||||
except Exception as e:
|
||||
errors = ['Error: {}'.format(e)]
|
||||
errors = ["Error: {}".format(e)]
|
||||
|
||||
return cls(success=False, solutions_enabled=None, errors=errors)
|
||||
|
||||
|
|
@ -55,7 +58,7 @@ class UpdateLastModule(relay.ClientIDMutation):
|
|||
@classmethod
|
||||
def mutate_and_get_payload(cls, root, info, **args):
|
||||
user = info.context.user
|
||||
id = args.get('id')
|
||||
id = args.get("id")
|
||||
|
||||
module = get_object(Module, id)
|
||||
if not module:
|
||||
|
|
@ -88,17 +91,19 @@ class SyncModuleVisibility(relay.ClientIDMutation):
|
|||
def mutate_and_get_payload(cls, root, info, **args):
|
||||
user = info.context.user
|
||||
if not user.is_teacher():
|
||||
raise Exception('Permission denied')
|
||||
raise Exception("Permission denied")
|
||||
|
||||
module_slug = args.get('module')
|
||||
template_id = args.get('template_school_class')
|
||||
school_class_id = args.get('school_class')
|
||||
module_slug = args.get("module")
|
||||
template_id = args.get("template_school_class")
|
||||
school_class_id = args.get("school_class")
|
||||
|
||||
module = Module.objects.get(slug=module_slug)
|
||||
template = get_object(SchoolClass, template_id)
|
||||
school_class = get_object(SchoolClass, school_class_id)
|
||||
if not template.is_user_in_schoolclass(user) or not school_class.is_user_in_schoolclass(user):
|
||||
raise Exception('Permission denied')
|
||||
if not template.is_user_in_schoolclass(
|
||||
user
|
||||
) or not school_class.is_user_in_schoolclass(user):
|
||||
raise Exception("Permission denied")
|
||||
|
||||
module.sync_from_school_class(template, school_class)
|
||||
|
||||
|
|
@ -114,8 +119,9 @@ class UpdateLastModuleLevel(relay.ClientIDMutation):
|
|||
@classmethod
|
||||
def mutate_and_get_payload(cls, root, info, **args):
|
||||
user = info.context.user
|
||||
id = args.get('id')
|
||||
id = args.get("id")
|
||||
module_level = get_object(ModuleLevel, id)
|
||||
|
||||
User.objects.filter(pk=user.id).update(last_module_level_id=module_level.id)
|
||||
user.last_module_level = module_level
|
||||
user.save()
|
||||
return cls(user=user)
|
||||
|
|
|
|||
Loading…
Reference in New Issue