serializers.py 919 Bytes
Newer Older
1
from picampaign.campaign.models import (Campaign, CampaignContact,
2
                                        Argumentary)
Aymeric Barantal's avatar
Aymeric Barantal committed
3
4
5
from rest_framework import serializers


6
7
8
9
10
11
12
class ArgumentarySerializer(serializers.ModelSerializer):

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


Aymeric Barantal's avatar
Aymeric Barantal committed
13
14
15
16
17
18
19
20
21
class CampaignSerializer(serializers.HyperlinkedModelSerializer):

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


class CampaignContactSerializer(serializers.HyperlinkedModelSerializer):

22
23
24
25
    first_name = serializers.Field(source='contact.first_name')
    last_name = serializers.Field(source='contact.last_name')
    phone = serializers.Field(source='contact.phone')
    groups = serializers.Field(source='all_groups')
Aymeric Barantal's avatar
Aymeric Barantal committed
26
27
28

    class Meta:
        model = CampaignContact
29
        fields = ('id', 'weight', 'first_name', 'last_name', 'phone', 'groups')