Fixed reference to section type
This commit is contained in:
@@ -83,9 +83,8 @@ class SectionSerializer(serializers.ModelSerializer):
|
||||
|
||||
class DocumentSerializer(serializers.ModelSerializer):
|
||||
|
||||
upload = serializers.URLField()
|
||||
upload = serializers.CharField()
|
||||
sections = SectionSerializer(many=True)
|
||||
#doctype = serializers.CharField(source='get_doctype_display')
|
||||
|
||||
#def to_internal_value(self, data):
|
||||
# r = requests.get(data['upload'], stream=True)
|
||||
@@ -97,8 +96,7 @@ class DocumentSerializer(serializers.ModelSerializer):
|
||||
|
||||
def to_representation(self, instance):
|
||||
data = super().to_representation(instance)
|
||||
if data['upload'][0] == '/':
|
||||
data['upload'] = 'http://localhost:8000' + (data['upload'])
|
||||
data['upload'] = instance.upload.url
|
||||
return data
|
||||
|
||||
def create(self, validated_data):
|
||||
@@ -169,6 +167,7 @@ from rest_framework import generics
|
||||
|
||||
class CollectionExportView(AuthorizedResourceMixin, generics.RetrieveAPIView):
|
||||
serializer_class = CollectionSerializer
|
||||
lookup_url_kwarg = 'collection'
|
||||
|
||||
def get_queryset(self):
|
||||
return Collection.objects.filter(administrators=self.request.user)
|
||||
@@ -177,7 +176,7 @@ class WorkExportView(AuthorizedResourceMixin, generics.RetrieveAPIView):
|
||||
serializer_class = WorkSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
return Work.objects.filter(collection__administrators=self.request.user)
|
||||
return Work.objects.filter(collection__administrators=self.request.user, collection=self.kwargs['collection'])
|
||||
|
||||
class WorkImportView(AuthorizedResourceMixin, generics.CreateAPIView):
|
||||
serializer_class = WorkSerializer
|
||||
|
||||
Reference in New Issue
Block a user