Refactor order creation and add configuration endpoints
Refactored order creation logic to use new serializers and transaction handling, improving validation and modularity. Introduced admin and public endpoints for shop configuration with sensitive fields protected. Enhanced Zásilkovna (Packeta) integration, including packet widget template, new API fields, and improved error handling. Added django-silk for profiling, updated requirements and settings, and improved frontend Orval config for API client generation.
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework import viewsets, mixins
|
||||
from rest_framework.permissions import IsAdminUser, AllowAny
|
||||
from .models import ShopConfiguration
|
||||
from .serializers import (
|
||||
ShopConfigurationAdminSerializer,
|
||||
ShopConfigurationPublicSerializer,
|
||||
)
|
||||
|
||||
# Create your views here.
|
||||
|
||||
#TODO: dej public tag pro view
|
||||
# rozdělit fieldy podle práv aby se třeba neexposelo citlivé údaje
|
||||
class _SingletonQuerysetMixin:
|
||||
def get_queryset(self):
|
||||
return ShopConfiguration.objects.filter(pk=1)
|
||||
|
||||
def get_object(self):
|
||||
return ShopConfiguration.get_solo()
|
||||
|
||||
|
||||
class ShopConfigurationAdminViewSet(_SingletonQuerysetMixin, viewsets.ModelViewSet):
|
||||
permission_classes = [IsAdminUser]
|
||||
serializer_class = ShopConfigurationAdminSerializer
|
||||
|
||||
|
||||
class ShopConfigurationPublicViewSet(_SingletonQuerysetMixin, viewsets.ReadOnlyModelViewSet):
|
||||
permission_classes = [AllowAny]
|
||||
serializer_class = ShopConfigurationPublicSerializer
|
||||
Reference in New Issue
Block a user