76 lines
2.7 KiB
Python
76 lines
2.7 KiB
Python
import graphene
|
|
|
|
|
|
class MutateContentBlock(graphene.relay.ClientIDMutation):
|
|
class Input:
|
|
id = None
|
|
|
|
title = graphene.String()
|
|
type = graphene.String()
|
|
|
|
module_slug = graphene.String(required=True)
|
|
# text params
|
|
# learnings_text = graphene.String()
|
|
# impact_text = graphene.String()
|
|
# measurement_text = graphene.String()
|
|
# measures_text = graphene.String()
|
|
# time_frame_text = graphene.String()
|
|
# resources_skills_text = graphene.String()
|
|
# commitment_support_text = graphene.String()
|
|
|
|
# user_module_progress = graphene.Field(UserModuleProgressNode)
|
|
|
|
@classmethod
|
|
def mutate_and_get_payload(cls, *args, **kwargs):
|
|
# user_module_progress = get_object_or_404(
|
|
# UserModuleProgress,
|
|
# user=get_current_user(),
|
|
# module__slug=kwargs.pop('module_slug')
|
|
# )
|
|
#
|
|
# for k, v in kwargs.items():
|
|
# setattr(user_module_progress, k, v)
|
|
#
|
|
# user_module_progress.save()
|
|
return cls(user_module_progress=user_module_progress)
|
|
|
|
|
|
# class UpdateImage(relay.ClientIDMutation):
|
|
# class Input:
|
|
# image = graphene.Argument(ImageUpdateInput)
|
|
# id = graphene.String(required=True)
|
|
#
|
|
# errors = graphene.List(graphene.String)
|
|
# updated_image = graphene.Field(ImageNode)
|
|
# tags = graphene.List(TagNode)
|
|
#
|
|
# @classmethod
|
|
# def mutate_and_get_payload(cls, *args, **kwargs):
|
|
# try:
|
|
# image_instance = get_object(Image, kwargs['id'])
|
|
# if image_instance:
|
|
# image_data = kwargs.get('image')
|
|
# updated_image = update_create_instance(image_instance, image_data, exception=['id', 'tags'])
|
|
# tag_slugs = image_data.get('tag_slugs', '')
|
|
# if tag_slugs is not None:
|
|
# tag_slugs = [t.strip() for t in tag_slugs.split(',') if t.strip()]
|
|
# tags = list(Tag.objects.filter(slug__in=tag_slugs))
|
|
# tag_slugs = [t for t in tag_slugs if t not in [e.slug for e in tags]]
|
|
# updated_image.tags.set(*(tags + tag_slugs))
|
|
#
|
|
# return cls(updated_image=updated_image, tags=Tag.objects.all())
|
|
# except ValidationError as e:
|
|
# errors = get_errors(e)
|
|
# except Exception as e:
|
|
# errors = ['Error: {}'.format(e)]
|
|
# else:
|
|
# errors = ['image not found']
|
|
#
|
|
# return cls(updated_image=None, tags=None, errors=errors)
|
|
|
|
|
|
class BookMutations(object):
|
|
# start_module_progress = StartModuleProgress.Field()
|
|
# delete_module_progress = DeleteModuleProgress.Field()
|
|
define_action_plan = MutateContentBlock.Field()
|