mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 09:05:41 +01:00
Fix: Should use image_by_id as image-field name / add pagination
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from rest_framework import viewsets, mixins, routers
|
||||
from rest_framework.filters import SearchFilter, OrderingFilter
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
from core import drf_api as api
|
||||
@@ -23,7 +24,10 @@ class ImageViewSet(mixins.CreateModelMixin, GenericViewSet):
|
||||
class PinViewSet(viewsets.ModelViewSet):
|
||||
queryset = Pin.objects.all()
|
||||
serializer_class = api.PinSerializer
|
||||
filter_fields = ('submitter__username',)
|
||||
filter_backends = (SearchFilter, OrderingFilter)
|
||||
search_fields = ('=submitter__username', )
|
||||
ordering_fields = ('id', )
|
||||
ordering = ('id', )
|
||||
permission_classes = [IsOwnerOrReadOnly("submitter"), ]
|
||||
|
||||
|
||||
|
||||
@@ -156,4 +156,6 @@ REST_FRAMEWORK = {
|
||||
'django_filters.rest_framework.DjangoFilterBackend',
|
||||
),
|
||||
'URL_FIELD_NAME': DRF_URL_FIELD_NAME,
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
|
||||
'PAGE_SIZE': 50,
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ $(window).load(function() {
|
||||
tags: cleanTags($('#pin-form-tags').val())
|
||||
};
|
||||
if (uploadedImage) {
|
||||
data.image_id = uploadedImage;
|
||||
data.image_by_id = uploadedImage;
|
||||
} else {
|
||||
data.url = $('#pin-form-image-url').val();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user