Commit f9198a2e authored by Lukas Burgey's avatar Lukas Burgey

Adapt serializers to the REST interface

Makes some serializers more terse, and makes unwanted fields read_only.
parent 8d0175e2
......@@ -62,16 +62,27 @@ class ServiceSerializer(serializers.ModelSerializer):
]
class CompactServiceSerializer(serializers.ModelSerializer):
class Meta:
model = Service
fields = [
'id',
'name',
'description',
]
class DeploymentStateSerializer(serializers.ModelSerializer):
service = ServiceSerializer()
site = SiteSerializer()
# why all the read_onlys: the rest interface exposes these fields, but the must not be changed
credential_states = CredentialStateSerializer(many=True, read_only=True)
credentials = serializers.JSONField(read_only=True)
questionnaire = serializers.JSONField()
credentials = serializers.JSONField()
credential_states = CredentialStateSerializer(many=True)
service = CompactServiceSerializer(read_only=True)
site = SiteSerializer(read_only=True)
class Meta:
model = DeploymentState
fields = [
fields = (
'credential_states',
'credentials',
'id',
......@@ -83,7 +94,11 @@ class DeploymentStateSerializer(serializers.ModelSerializer):
'site',
'state',
'state_target',
]
)
read_only_fields = (
'state',
'message',
)
DEPLOYMENT_FIELDS = (
......
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