serializers.py 935 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

from rest_framework import serializers

from .. import models
from ..frontend import serializers as frontend_serializers


class UserSerializer(serializers.ModelSerializer):
    groups = frontend_serializers.GroupSerializer(many=True)

    class Meta:
        model = models.User
        fields = [
                'sub', 'email', 'groups'
                ]


18
class DeploymentSerializer(serializers.ModelSerializer):
19
20
    user = UserSerializer()
    ssh_keys = frontend_serializers.SSHPublicKeySerializer(many=True)
21
22
    ssh_keys_to_withdraw = frontend_serializers.SSHPublicKeySerializer(
            many=True)
23
24
25

    class Meta:
        model = models.Deployment
26
        fields = ['user', 'ssh_keys', 'ssh_keys_to_withdraw']
27
28
29
30
31


class DeploymentsSerializer(serializers.Serializer):
    services = serializers.DictField(
            child=serializers.ListField(
32
                child=DeploymentSerializer()
33
34
                )
            )