コード例 #1
0
ファイル: serializers.py プロジェクト: HatimKH/OIPA
class LocationSerializer(DynamicFieldsModelSerializer):
    class LocationIdSerializer(serializers.Serializer):
        vocabulary = VocabularySerializer(source='location_id_vocabulary')
        code = serializers.CharField(source='location_id_code')

    class PointSerializer(serializers.Serializer):
        pos = PointField(source='point_pos')
        srsName = serializers.CharField(source="point_srs_name")

    class AdministrativeSerializer(serializers.ModelSerializer):
        code = serializers.CharField()
        vocabulary = VocabularySerializer()

        class Meta:
            model = iati_models.LocationAdministrative
            fields = (
                'code',
                'vocabulary',
                'level',
            )

    url = serializers.HyperlinkedIdentityField(
        view_name='locations:location-detail')
    activity = ActivitySerializer(read_only=True,
                                  fields=('id', 'url', 'title'))
    location_reach = CodelistSerializer()
    location_id = LocationIdSerializer(source='*')
    name = NarrativeContainerSerializer(many=True, source="locationname_set")
    description = NarrativeContainerSerializer(
        many=True, source="locationdescription_set")
    activity_description = NarrativeContainerSerializer(
        many=True, source="locationactivitydescription_set")
    administrative = AdministrativeSerializer(
        many=True, source="locationadministrative_set")
    point = PointSerializer(source="*")
    exactness = CodelistSerializer()
    location_class = CodelistSerializer()
    feature_designation = CodelistCategorySerializer()

    class Meta:
        model = iati_models.Location
        fields = (
            'id',
            'url',
            'activity',
            'ref',
            'location_reach',
            'location_id',
            'name',
            'description',
            'activity_description',
            'administrative',
            'point',
            'exactness',
            'location_class',
            'feature_designation',
        )
コード例 #2
0
ファイル: serializers.py プロジェクト: HatimKH/OIPA
class ResultSerializer(serializers.ModelSerializer):
    type = CodelistSerializer() 
    title = NarrativeContainerSerializer(source="resulttitle")
    description = NarrativeContainerSerializer(source="resultdescription")
    indicator = ResultIndicatorSerializer(source='resultindicator_set', many=True)

    class Meta:
        model = iati_models.Result
        fields = (
            'title',
            'description',
            'indicator',
            'type',
            'aggregation_status',
        )
コード例 #3
0
ファイル: serializers.py プロジェクト: HatimKH/OIPA
class ResultIndicatorSerializer(serializers.ModelSerializer):
    title = NarrativeContainerSerializer(source="resultindicatortitle")
    description = NarrativeContainerSerializer(source="resultindicatordescription")
    #  TODO 2.02 reference = ? 
    baseline = ResultIndicatorBaselineSerializer(source="*")
    period = ResultIndicatorPeriodSerializer(source='resultindicatorperiod_set', many=True)
    measure = CodelistSerializer()

    class Meta:
        model = iati_models.ResultIndicator
        fields = (
            'title',
            'description',
            'baseline',
            'period',
            'measure',
            'ascending'
        )
コード例 #4
0
ファイル: serializers.py プロジェクト: HatimKH/OIPA
class ContactInfoSerializer(serializers.ModelSerializer):
    type = CodelistSerializer()
    organisation = NarrativeContainerSerializer()
    department = NarrativeContainerSerializer()
    person_name = NarrativeContainerSerializer()
    job_title = NarrativeContainerSerializer()
    mailing_address = NarrativeContainerSerializer()

    class Meta:
        model = iati_models.ContactInfo
        fields = (
            'type',
            'organisation',
            'department',
            'person_name',
            'job_title',
            'telephone',
            'email',
            'website',
            'mailing_address',
        )
コード例 #5
0
class DocumentLinkSerializer(serializers.ModelSerializer):
    class DocumentDateSerializer(serializers.Serializer):
        iso_date = serializers.DateField()

    format = CodelistSerializer(source='file_format')
    categories = DocumentCategorySerializer(many=True)
    title = NarrativeContainerSerializer(source="documentlinktitle")
    document_date = DocumentDateSerializer(source="*")

    class Meta:
        model = iati_models.DocumentLink
        fields = (
            'url',
            'format',
            'categories',
            'title',
            'document_date',
        )
コード例 #6
0
ファイル: serializers.py プロジェクト: HatimKH/OIPA
class ResultIndicatorBaselineSerializer(serializers.Serializer):
    year = serializers.CharField(source='baseline_year')
    value = serializers.CharField(source='baseline_value')
    comment = NarrativeContainerSerializer(source="resultindicatorbaselinecomment")
コード例 #7
0
ファイル: serializers.py プロジェクト: HatimKH/OIPA
class ResultIndicatorPeriodActualSerializer(serializers.Serializer):
    value = serializers.DecimalField(source='actual', max_digits=25, decimal_places=10)
    comment = NarrativeContainerSerializer(source="resultindicatorperiodactualcomment")
    location = ResultIndicatorPeriodLocationSerializer(many=True, source="resultindicatorperiodactuallocation_set")
    dimension = ResultIndicatorPeriodDimensionSerializer(many=True, source="resultindicatorperiodactualdimension_set")