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