Added back collections method for collection detail

This commit is contained in:
dormantman 2019-12-11 17:58:39 +03:00
parent 0b1b960108
commit 6cbfc38c9c
2 changed files with 17 additions and 1 deletions

View File

@ -1,4 +1,5 @@
"""Collection common urlpaths."""
from django.urls import path
from rest_framework.routers import SimpleRouter
from collection.views import back as views
@ -7,4 +8,9 @@ app_name = 'collection'
router = SimpleRouter()
router.register(r'', views.CollectionBackOfficeViewSet)
urlpatterns = router.urls
urlpatterns = [
path('/<int:pk>/', views.CollectionBackOfficeView.as_view(), name='detail'),
]
urlpatterns += router.urls

View File

@ -1,3 +1,4 @@
from rest_framework import generics
from rest_framework import permissions
from rest_framework import viewsets, mixins
@ -47,3 +48,12 @@ class CollectionBackOfficeViewSet(mixins.CreateModelMixin,
collection.establishments.remove(related_object)
elif obj_type == self.bind_object_serializer_class.PRODUCT:
collection.products.remove(related_object)
class CollectionBackOfficeView(generics.GenericAPIView):
"""ViewS for Collection model."""
pagination_class = None
permission_classes = (permissions.IsAuthenticated,)
queryset = models.Collection.objects.all()
serializer_class = serializers.CollectionBackOfficeSerializer