serializers.py 862 Bytes
Newer Older
1 2
from picampaign.campaign.models import (Campaign, CampaignContact, Contact,
                                        Argumentary)
Aymeric Barantal's avatar
Aymeric Barantal committed
3 4 5 6 7 8 9 10 11 12
from rest_framework import serializers


class ContactSerializer(serializers.ModelSerializer):

    class Meta:
        model = Contact
        fields = ('id', 'first_name', 'last_name', 'phone')


13 14 15 16 17 18 19
class ArgumentarySerializer(serializers.ModelSerializer):

    class Meta:
        model = Argumentary
        fields = ('lang', 'text')


Aymeric Barantal's avatar
Aymeric Barantal committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33
class CampaignSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Campaign
        fields = ('id', 'title', 'description', 'start_date', 'end_date')


class CampaignContactSerializer(serializers.HyperlinkedModelSerializer):

    contact = ContactSerializer(many=False)

    class Meta:
        model = CampaignContact
        fields = ('id', 'weight', 'contact')