Commit c1649a00 authored by lukas.burgey's avatar lukas.burgey
Browse files

Merge branch 'questionnaire' into dev

parents 19e334e1 0df7ff7a
Pipeline #121686 passed with stage
in 1 minute and 27 seconds
# we don't need to deserialize, so we do not implement the abstract methods
# pylint: disable=abstract-method
import logging
from django_mysql.models import JSONField
from rest_framework.serializers import Serializer, ModelSerializer, DictField, ListField, CharField
from rest_polymorphic.serializers import PolymorphicSerializer
......@@ -10,6 +12,8 @@ from feudal.backend.models.users import User, SSHPublicKey
from feudal.backend.models.deployments import Deployment, VODeployment, ServiceDeployment, DeploymentState, CredentialState
from feudal.backend.models.auth.serializers.clients import VOSerializer
LOGGER = logging.getLogger(__name__)
class ServiceSerializer(ModelSerializer):
class Meta:
......@@ -132,3 +136,29 @@ class DeploymentStateSerializer(ModelSerializer):
read_only_fields = (
def update(self, instance, validated_data):
LOGGER.debug('Updating %s', instance)
instance.state = validated_data.get('state', instance.state)
instance.message = validated_data.get('message', instance.message)
instance.credentials = validated_data.get('credentials', instance.credentials)
# merge new questionnaire / answers value into the existing dictionary
if 'questionnaire' in validated_data:
new_questionnaire = validated_data.get('questionnaire')
for key in new_questionnaire:
question = new_questionnaire[key]
if instance.questionnaire.get(key, None) != question:
LOGGER.debug('Question %s = %s', key, question)
instance.questionnaire[key] = question
if 'questionnaire_answers' in validated_data:
new_questionnaire_answers = validated_data.get('questionnaire_answers')
for key in new_questionnaire_answers:
new_answer = new_questionnaire_answers[key]
if instance.questionnaire_answers.get(key, None) != new_answer:
LOGGER.debug('Questionnaire answer %s = %s', key, new_answer)
instance.questionnaire_answers[key] = new_answer
return instance
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment