예제 #1
0
class WebLinkSerializer(serializers.HyperlinkedModelSerializer):
    document_types = DocumentTypeSerializer(read_only=True, many=True)

    class Meta:
        extra_kwargs = {
            'url': {
                'lookup_url_kwarg': 'pk',
                'view_name': 'rest_api:web_link-detail'
            },
        }
        fields = ('document_types', 'enabled', 'id', 'label', 'template',
                  'url')
        model = WebLink
예제 #2
0
class SmartLinkSerializer(serializers.HyperlinkedModelSerializer):
    conditions_url = serializers.HyperlinkedIdentityField(
        view_name='rest_api:smartlinkcondition-list')
    document_types = DocumentTypeSerializer(read_only=True, many=True)

    class Meta:
        extra_kwargs = {
            'url': {
                'view_name': 'rest_api:smartlink-detail'
            },
        }
        fields = ('conditions_url', 'document_types', 'dynamic_label',
                  'enabled', 'label', 'id', 'url')
        model = SmartLink
예제 #3
0
class DocumentTypeMetadataTypeSerializer(serializers.HyperlinkedModelSerializer
                                         ):
    document_type = DocumentTypeSerializer(read_only=True)
    metadata_type = MetadataTypeSerializer(read_only=True)
    url = serializers.SerializerMethodField()

    class Meta:
        fields = ('document_type', 'id', 'metadata_type', 'required', 'url')
        model = DocumentTypeMetadataType

    def get_url(self, instance):
        return reverse('rest_api:documenttypemetadatatype-detail',
                       args=(instance.document_type.pk, instance.pk),
                       request=self.context['request'],
                       format=self.context['format'])