add CRUD collections for back
This commit is contained in:
parent
12d44c0a0d
commit
2cd7755d7e
|
|
@ -1,9 +1,33 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from location.models import Country
|
||||||
|
from location.serializers import CountrySimpleSerializer
|
||||||
|
from collection.serializers.common import CollectionBaseSerializer
|
||||||
from collection import models
|
from collection import models
|
||||||
|
|
||||||
|
|
||||||
class CollectionBackOfficeSerializer(serializers.ModelSerializer):
|
class CollectionBackOfficeSerializer(CollectionBaseSerializer):
|
||||||
"""Collection serializer."""
|
"""Collection back serializer."""
|
||||||
|
country_id = serializers.PrimaryKeyRelatedField(
|
||||||
|
source='country', write_only=True,
|
||||||
|
queryset=Country.objects.all())
|
||||||
|
collection_type_display = serializers.CharField(
|
||||||
|
source='get_collection_type_display', read_only=True)
|
||||||
|
country = CountrySimpleSerializer(read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Collection
|
model = models.Collection
|
||||||
fields = '__all__'
|
fields = CollectionBaseSerializer.Meta.fields + [
|
||||||
|
'id',
|
||||||
|
'name',
|
||||||
|
'collection_type',
|
||||||
|
'collection_type_display',
|
||||||
|
'is_publish',
|
||||||
|
'on_top',
|
||||||
|
'country',
|
||||||
|
'country_id',
|
||||||
|
'block_size',
|
||||||
|
'description',
|
||||||
|
'slug',
|
||||||
|
'start',
|
||||||
|
'end',
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,5 @@ app_name = 'collection'
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.CollectionListCreateView.as_view(), name='list-create'),
|
path('', views.CollectionListCreateView.as_view(), name='list-create'),
|
||||||
|
path('<int:pk>/', views.CollectionRUDView.as_view(), name='rud-collection'),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from rest_framework import generics, permissions
|
from rest_framework import generics, permissions
|
||||||
from collection import models
|
from collection import models
|
||||||
from collection.serializers import common, back
|
from collection.serializers import back
|
||||||
|
|
||||||
|
|
||||||
class CollectionListCreateView(generics.ListCreateAPIView):
|
class CollectionListCreateView(generics.ListCreateAPIView):
|
||||||
|
|
@ -16,4 +16,4 @@ class CollectionRUDView(generics.RetrieveUpdateDestroyAPIView):
|
||||||
queryset = models.Collection.objects.all()
|
queryset = models.Collection.objects.all()
|
||||||
serializer_class = back.CollectionBackOfficeSerializer
|
serializer_class = back.CollectionBackOfficeSerializer
|
||||||
# todo: conf. permissions by TT
|
# todo: conf. permissions by TT
|
||||||
permission_classes = (permissions.IsAuthenticated, )
|
permission_classes = (permissions.IsAuthenticated, )
|
||||||
|
|
|
||||||
|
|
@ -590,7 +590,7 @@ class Position(BaseAttributes, TranslatedFieldsMixin):
|
||||||
|
|
||||||
|
|
||||||
class EstablishmentEmployeeQuerySet(models.QuerySet):
|
class EstablishmentEmployeeQuerySet(models.QuerySet):
|
||||||
"""Extended queryset for EstablishmEntemployee model."""
|
"""Extended queryset for EstablishmentEmployee model."""
|
||||||
|
|
||||||
def actual(self):
|
def actual(self):
|
||||||
"""Actual objects.."""
|
"""Actual objects.."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user