* Cleanup
This commit is contained in:
parent
e51d05cb3d
commit
a95ff1d738
|
|
@ -512,6 +512,7 @@ class Checklist(models.Model):
|
|||
# Default commission
|
||||
commission = GlobalSettings.load().commission_rub
|
||||
|
||||
# For big orders there is an additional commission
|
||||
if self.price_rub > 150_000:
|
||||
commission = max(commission, self.price_rub * Decimal(settings.COMMISSION_OVER_150K))
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,9 @@ router.register(r'cdek', views.CDEKAPI, basename='cdek')
|
|||
router.register(r'gifts', views.GiftAPI, basename='gifts')
|
||||
router.register(r'poizon', views.PoizonAPI, basename='poizon')
|
||||
router.register(r'promo', views.PromoCodeAPI, basename='promo')
|
||||
router.register(r'category', views.CategoryAPI, basename='category')
|
||||
|
||||
urlpatterns = [
|
||||
path("category/", views.CategoryAPI.as_view()),
|
||||
path("category/<int:id>", views.CategoryAPI.as_view()),
|
||||
|
||||
path("payment/", views.PaymentMethodsAPI.as_view()),
|
||||
path("settings/", views.GlobalSettingsAPI.as_view()),
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from datetime import timedelta
|
|||
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from django.db.models import F, Count, Sum, OuterRef, Subquery
|
||||
from django.db.models import F, Count, Sum
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from rest_framework import generics, permissions, mixins, status, viewsets
|
||||
from rest_framework.decorators import action
|
||||
|
|
@ -114,21 +114,16 @@ class ChecklistAPI(viewsets.ModelViewSet):
|
|||
return obj
|
||||
|
||||
|
||||
class CategoryAPI(mixins.ListModelMixin, mixins.UpdateModelMixin, generics.GenericAPIView):
|
||||
class CategoryAPI(mixins.ListModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, viewsets.GenericViewSet):
|
||||
serializer_class = CategorySerializer
|
||||
permission_classes = [IsManager | ReadOnly]
|
||||
lookup_field = 'id'
|
||||
queryset = Category.objects.all()
|
||||
|
||||
def get_queryset(self):
|
||||
return Category.objects.all()
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
def list(self, request, *args, **kwargs):
|
||||
categories_qs = Category.objects.root_nodes()
|
||||
return Response(CategoryFullSerializer(categories_qs, many=True).data)
|
||||
|
||||
def patch(self, request, *args, **kwargs):
|
||||
return self.partial_update(request, *args, **kwargs)
|
||||
|
||||
|
||||
class GlobalSettingsAPI(generics.RetrieveUpdateAPIView):
|
||||
serializer_class = GlobalSettingsSerializer
|
||||
|
|
@ -145,12 +140,11 @@ class GlobalSettingsAPI(generics.RetrieveUpdateAPIView):
|
|||
return GlobalSettings.load()
|
||||
|
||||
|
||||
# TODO: update to GenericViewSet
|
||||
class PaymentMethodsAPI(generics.GenericAPIView):
|
||||
serializer_class = PaymentMethodSerializer
|
||||
permission_classes = [IsManager | ReadOnly]
|
||||
|
||||
def get_queryset(self):
|
||||
return PaymentMethod.objects.all()
|
||||
queryset = PaymentMethod.objects.all()
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
qs = self.get_queryset()
|
||||
|
|
|
|||
|
|
@ -10,3 +10,6 @@ class CRMException(APIException):
|
|||
detail = self.default_detail
|
||||
|
||||
self.detail = {'error': detail}
|
||||
|
||||
|
||||
# TODO: exceptions with a same template: ok / error_code / error_message
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user