Swap serializer mutation for form mutation

This commit is contained in:
Ramon Wenger 2022-11-22 16:11:19 +01:00
parent e1d9df7d31
commit 6a2859e641
4 changed files with 24 additions and 16 deletions

View File

@ -1,15 +1,14 @@
import graphene
from graphene_django.forms.mutation import DjangoModelFormMutation
from graphene_django.rest_framework.mutation import SerializerMutation
from vbv_lernwelt.feedback.forms import FeedbackForm
from vbv_lernwelt.feedback.graphql.types import FeedbackType
from vbv_lernwelt.feedback.serializers import FeedbackSerializer
class SendFeedback(DjangoModelFormMutation):
feedback = graphene.Field(FeedbackType)
class SendFeedback(SerializerMutation):
# feedback = graphene.Field(FeedbackType)
class Meta:
form_class = FeedbackForm
# form_class = FeedbackForm
serializer_class = FeedbackSerializer
class Mutation(object):

View File

@ -3,6 +3,6 @@ from graphene_django import DjangoObjectType
from vbv_lernwelt.feedback.models import Feedback
class FeedbackType(DjangoObjectType):
class Meta:
model = Feedback
# class FeedbackType(DjangoObjectType):
# class Meta:
# model = Feedback

View File

@ -42,16 +42,16 @@ class Feedback(models.Model):
EIGHTY = 80, "80%"
HUNDRED = 100, "100%"
satisfaction = FeedbackIntegerField(choices=RatingChoices.choices)
goal_attainment = FeedbackIntegerField(choices=RatingChoices.choices)
proficiency = models.IntegerField(choices=PercentageChoices.choices)
satisfaction = FeedbackIntegerField()
goal_attainment = FeedbackIntegerField()
proficiency = models.IntegerField()
received_materials = models.BooleanField()
materials_rating = FeedbackIntegerField(blank=True)
instructor_competence = FeedbackIntegerField(choices=RatingChoices.choices)
instructor_respect = FeedbackIntegerField(choices=RatingChoices.choices)
instructor_competence = FeedbackIntegerField()
instructor_respect = FeedbackIntegerField()
instructor_open_feedback = models.TextField()
would_recommend = models.BooleanField()
course_positive_feedback = models.TextField()
course_negative_feedback = models.TextField()
how_discovered = models.CharField(max_length=1, choices=DiscoveredChoices.choices)
how_discovered = models.CharField(max_length=1)
motivation = models.ManyToManyField(Motivation)

View File

@ -0,0 +1,9 @@
from rest_framework import serializers
from vbv_lernwelt.feedback.models import Feedback
class FeedbackSerializer(serializers.ModelSerializer):
class Meta:
model = Feedback
fields = "__all__"