feat: add prettier for code formatting

refactor: update route for downloader to apps/downloader

chore: remove unused filler model files

refactor: delete Default layout component and its imports
This commit is contained in:
2025-12-20 23:18:20 +01:00
parent 713c94d7e9
commit 0346180d01
17 changed files with 314 additions and 286 deletions

View File

@@ -38,7 +38,7 @@ from rest_framework_simplejwt.views import TokenObtainPairView
# Custom Token obtaining view
@extend_schema(
tags=["Authentication", "public"],
tags=["account", "public"],
summary="Obtain JWT access and refresh tokens (cookie-based)",
description="Authenticate user and obtain JWT access and refresh tokens. You can use either email or username.",
request=CustomTokenObtainPairSerializer,
@@ -107,7 +107,7 @@ class CookieTokenObtainPairView(TokenObtainPairView):
return super().validate(attrs)
@extend_schema(
tags=["Authentication", "public"],
tags=["account", "public"],
summary="Refresh JWT token using cookie",
description="Refresh JWT access and refresh tokens using the refresh token stored in cookie.",
responses={
@@ -163,7 +163,7 @@ class CookieTokenRefreshView(APIView):
#---------------------------------------------LOGOUT------------------------------------------------
@extend_schema(
tags=["Authentication", "public"],
tags=["account", "public"],
summary="Logout user (delete access and refresh token cookies)",
description="Logs out the user by deleting access and refresh token cookies.",
responses={
@@ -185,7 +185,7 @@ class LogoutView(APIView):
#--------------------------------------------------------------------------------------------------------------
@extend_schema(
tags=["User"],
tags=["account"],
summary="List, retrieve, update, and delete users.",
description="Displays all users with filtering and ordering options. Requires authentication and appropriate role.",
responses={
@@ -223,7 +223,7 @@ class UserView(viewsets.ModelViewSet):
}
@extend_schema(
tags=["User"],
tags=["account"],
summary="Get permissions based on user role and action.",
description="Determines permissions for various actions based on user role and ownership.",
responses={
@@ -261,7 +261,7 @@ class UserView(viewsets.ModelViewSet):
# Get current user data
@extend_schema(
tags=["User"],
tags=["account"],
summary="Get current authenticated user",
description="Returns details of the currently authenticated user based on JWT token or session.",
responses={
@@ -281,7 +281,7 @@ class CurrentUserView(APIView):
#1. registration API
@extend_schema(
tags=["User Registration"],
tags=["account", "public"],
summary="Register a new user (company or individual)",
description="Register a new user (company or individual). The user will receive an email with a verification link.",
request=UserRegistrationSerializer,
@@ -313,7 +313,7 @@ class UserRegistrationViewSet(ModelViewSet):
#2. confirming email
@extend_schema(
tags=["User Registration"],
tags=["account", "public"],
summary="Verify user email via link",
description="Verify user email using the link with uid and token.",
parameters=[
@@ -346,7 +346,7 @@ class EmailVerificationView(APIView):
#1. PasswordReset + send Email
@extend_schema(
tags=["User password reset"],
tags=["account", "public"],
summary="Request password reset (send email)",
description="Request password reset by providing registered email. An email with instructions will be sent.",
request=PasswordResetRequestSerializer,
@@ -376,7 +376,7 @@ class PasswordResetRequestView(APIView):
#2. Confirming reset
@extend_schema(
tags=["User password reset"],
tags=["account", "public"],
summary="Confirm password reset via token",
description="Confirm password reset using token from email.",
request=PasswordResetConfirmSerializer,

View File

@@ -3,12 +3,14 @@ from rest_framework.response import Response
from rest_framework import status, viewsets
from rest_framework.permissions import AllowAny, IsAdminUser
from rest_framework.authentication import SessionAuthentication
from drf_spectacular.utils import extend_schema, extend_schema_view
from .models import ContactMe
from .serializer import ContactMeSerializer
from .tasks import send_contact_me_email_task
@extend_schema(tags=["advertisement", "public"])
class ContactMePublicView(APIView):
permission_classes = [AllowAny]
# Avoid CSRF for public endpoint by disabling SessionAuthentication
@@ -39,6 +41,14 @@ class ContactMePublicView(APIView):
return Response({"id": cm.id, "status": "queued"}, status=status.HTTP_201_CREATED)
@extend_schema_view(
list=extend_schema(tags=["advertisement"], summary="List contact messages (admin)"),
retrieve=extend_schema(tags=["advertisement"], summary="Retrieve contact message (admin)"),
create=extend_schema(tags=["advertisement"], summary="Create contact message (admin)"),
partial_update=extend_schema(tags=["advertisement"], summary="Update contact message (admin)"),
update=extend_schema(tags=["advertisement"], summary="Replace contact message (admin)"),
destroy=extend_schema(tags=["advertisement"], summary="Delete contact message (admin)"),
)
class ContactMeAdminViewSet(viewsets.ModelViewSet):
queryset = ContactMe.objects.all().order_by("-sent_at")
serializer_class = ContactMeSerializer

View File

@@ -414,6 +414,11 @@ class PaymentReadSerializer(serializers.ModelSerializer):
class OrderMiniSerializer(serializers.ModelSerializer):
status = serializers.ChoiceField(
choices=Order.OrderStatus.choices,
read_only=True
)
class Meta:
model = Order
fields = ["id", "status", "total_price", "created_at"]
@@ -421,6 +426,10 @@ class OrderMiniSerializer(serializers.ModelSerializer):
class OrderReadSerializer(serializers.ModelSerializer):
status = serializers.ChoiceField(
choices=Order.OrderStatus.choices,
read_only=True
)
items = OrderItemReadSerializer(many=True, read_only=True)
carrier = CarrierReadSerializer(read_only=True)
payment = PaymentReadSerializer(read_only=True)

View File

@@ -44,8 +44,8 @@ from .serializers import (
#FIXME: uravit view na nový order serializer
@extend_schema_view(
list=extend_schema(tags=["Orders"], summary="List Orders (public)"),
retrieve=extend_schema(tags=["Orders"], summary="Retrieve Order (public)"),
list=extend_schema(tags=["commerce", "public"], summary="List Orders (public)"),
retrieve=extend_schema(tags=["commerce", "public"], summary="Retrieve Order (public)"),
)
class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
queryset = Order.objects.select_related("carrier", "payment").prefetch_related(
@@ -63,7 +63,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
return OrderReadSerializer
@extend_schema(
tags=["Order"],
tags=["commerce", "public"],
summary="Create Order (public)",
request=OrderCreateSerializer,
responses={201: OrderReadSerializer},
@@ -101,7 +101,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
# -- List mini orders -- (public) --
@action(detail=False, methods=["get"], url_path="detail")
@extend_schema(
tags=["Orders"],
tags=["commerce", "public"],
summary="List mini orders (public)",
responses={200: OrderMiniSerializer(many=True)},
)
@@ -119,7 +119,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
# -- Get order items -- (public) --
@action(detail=True, methods=["get"], url_path="items")
@extend_schema(
tags=["Orders"],
tags=["commerce", "public"],
summary="List order items (public)",
responses={200: OrderItemReadSerializer(many=True)},
)
@@ -132,7 +132,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
# -- Get order carrier -- (public) --
@action(detail=True, methods=["get"], url_path="carrier")
@extend_schema(
tags=["Orders"],
tags=["commerce", "public"],
summary="Get order carrier (public)",
responses={200: CarrierReadSerializer},
)
@@ -144,7 +144,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
# -- Get order payment -- (public) --
@action(detail=True, methods=["get"], url_path="payment")
@extend_schema(
tags=["Orders"],
tags=["commerce", "public"],
summary="Get order payment (public)",
responses={200: PaymentReadSerializer},
)
@@ -161,7 +161,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
permission_classes=[IsAdminUser],
)
@extend_schema(
tags=["Orders"],
tags=["commerce"],
summary="Mark carrier ready to pickup (admin)",
request=None,
responses={200: CarrierReadSerializer},
@@ -183,7 +183,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
permission_classes=[IsAdminUser],
)
@extend_schema(
tags=["Orders"],
tags=["commerce"],
summary="Start ordering shipping (admin)",
request=None,
responses={200: CarrierReadSerializer},
@@ -202,7 +202,7 @@ class OrderViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.Ge
class OrderInvoice(viewsets.ViewSet):
@action(detail=True, methods=["get"], url_path="generate-invoice")
@extend_schema(
tags=["Orders"],
tags=["commerce", "public"],
summary="Get Invoice PDF for Order (public)",
responses={200: "PDF File"},
)
@@ -237,12 +237,12 @@ class AdminOnlyForPatchOtherwisePublic(AllowAny.__class__):
# ---------- Public/admin viewsets ----------
@extend_schema_view(
list=extend_schema(tags=["Products"], summary="List products (public)"),
retrieve=extend_schema(tags=["Products"], summary="Retrieve product (public)"),
create=extend_schema(tags=["Products"], summary="Create product (auth required)"),
partial_update=extend_schema(tags=["Products"], summary="Update product (auth required)"),
update=extend_schema(tags=["Products"], summary="Replace product (auth required)"),
destroy=extend_schema(tags=["Products"], summary="Delete product (auth required)"),
list=extend_schema(tags=["commerce", "public"], summary="List products (public)"),
retrieve=extend_schema(tags=["commerce", "public"], summary="Retrieve product (public)"),
create=extend_schema(tags=["commerce"], summary="Create product (auth required)"),
partial_update=extend_schema(tags=["commerce"], summary="Update product (auth required)"),
update=extend_schema(tags=["commerce"], summary="Replace product (auth required)"),
destroy=extend_schema(tags=["commerce"], summary="Delete product (auth required)"),
)
class ProductViewSet(viewsets.ModelViewSet):
queryset = Product.objects.all()
@@ -255,12 +255,12 @@ class ProductViewSet(viewsets.ModelViewSet):
@extend_schema_view(
list=extend_schema(tags=["Categories"], summary="List categories (public)"),
retrieve=extend_schema(tags=["Categories"], summary="Retrieve category (public)"),
create=extend_schema(tags=["Categories"], summary="Create category (auth required)"),
partial_update=extend_schema(tags=["Categories"], summary="Update category (auth required)"),
update=extend_schema(tags=["Categories"], summary="Replace category (auth required)"),
destroy=extend_schema(tags=["Categories"], summary="Delete category (auth required)"),
list=extend_schema(tags=["commerce", "public"], summary="List categories (public)"),
retrieve=extend_schema(tags=["commerce", "public"], summary="Retrieve category (public)"),
create=extend_schema(tags=["commerce"], summary="Create category (auth required)"),
partial_update=extend_schema(tags=["commerce"], summary="Update category (auth required)"),
update=extend_schema(tags=["commerce"], summary="Replace category (auth required)"),
destroy=extend_schema(tags=["commerce"], summary="Delete category (auth required)"),
)
class CategoryViewSet(viewsets.ModelViewSet):
queryset = Category.objects.all()
@@ -273,12 +273,12 @@ class CategoryViewSet(viewsets.ModelViewSet):
@extend_schema_view(
list=extend_schema(tags=["Product Images"], summary="List product images (public)"),
retrieve=extend_schema(tags=["Product Images"], summary="Retrieve product image (public)"),
create=extend_schema(tags=["Product Images"], summary="Create product image (auth required)"),
partial_update=extend_schema(tags=["Product Images"], summary="Update product image (auth required)"),
update=extend_schema(tags=["Product Images"], summary="Replace product image (auth required)"),
destroy=extend_schema(tags=["Product Images"], summary="Delete product image (auth required)"),
list=extend_schema(tags=["commerce", "public"], summary="List product images (public)"),
retrieve=extend_schema(tags=["commerce", "public"], summary="Retrieve product image (public)"),
create=extend_schema(tags=["commerce"], summary="Create product image (auth required)"),
partial_update=extend_schema(tags=["commerce"], summary="Update product image (auth required)"),
update=extend_schema(tags=["commerce"], summary="Replace product image (auth required)"),
destroy=extend_schema(tags=["commerce"], summary="Delete product image (auth required)"),
)
class ProductImageViewSet(viewsets.ModelViewSet):
queryset = ProductImage.objects.all()
@@ -291,12 +291,12 @@ class ProductImageViewSet(viewsets.ModelViewSet):
@extend_schema_view(
list=extend_schema(tags=["Discount Codes"], summary="List discount codes (public)"),
retrieve=extend_schema(tags=["Discount Codes"], summary="Retrieve discount code (public)"),
create=extend_schema(tags=["Discount Codes"], summary="Create discount code (auth required)"),
partial_update=extend_schema(tags=["Discount Codes"], summary="Update discount code (auth required)"),
update=extend_schema(tags=["Discount Codes"], summary="Replace discount code (auth required)"),
destroy=extend_schema(tags=["Discount Codes"], summary="Delete discount code (auth required)"),
list=extend_schema(tags=["commerce", "public"], summary="List discount codes (public)"),
retrieve=extend_schema(tags=["commerce", "public"], summary="Retrieve discount code (public)"),
create=extend_schema(tags=["commerce"], summary="Create discount code (auth required)"),
partial_update=extend_schema(tags=["commerce"], summary="Update discount code (auth required)"),
update=extend_schema(tags=["commerce"], summary="Replace discount code (auth required)"),
destroy=extend_schema(tags=["commerce"], summary="Delete discount code (auth required)"),
)
class DiscountCodeViewSet(viewsets.ModelViewSet):
queryset = DiscountCode.objects.all()
@@ -310,12 +310,12 @@ class DiscountCodeViewSet(viewsets.ModelViewSet):
# -- Refund (Admin only) --
@extend_schema_view(
list=extend_schema(tags=["Refunds"], summary="List refunds (admin)"),
retrieve=extend_schema(tags=["Refunds"], summary="Retrieve refund (admin)"),
create=extend_schema(tags=["Refunds"], summary="Create refund (admin)"),
partial_update=extend_schema(tags=["Refunds"], summary="Update refund (admin)"),
update=extend_schema(tags=["Refunds"], summary="Replace refund (admin)"),
destroy=extend_schema(tags=["Refunds"], summary="Delete refund (admin)"),
list=extend_schema(tags=["commerce"], summary="List refunds (admin)"),
retrieve=extend_schema(tags=["commerce"], summary="Retrieve refund (admin)"),
create=extend_schema(tags=["commerce"], summary="Create refund (admin)"),
partial_update=extend_schema(tags=["commerce"], summary="Update refund (admin)"),
update=extend_schema(tags=["commerce"], summary="Replace refund (admin)"),
destroy=extend_schema(tags=["commerce"], summary="Delete refund (admin)"),
)
class RefundViewSet(viewsets.ModelViewSet):
queryset = Refund.objects.select_related("order").all().order_by("-created_at")

View File

@@ -1,5 +1,6 @@
from rest_framework import viewsets, mixins
from rest_framework.permissions import IsAdminUser, AllowAny
from drf_spectacular.utils import extend_schema, extend_schema_view
from .models import SiteConfiguration
from .serializers import (
SiteConfigurationAdminSerializer,
@@ -15,11 +16,23 @@ class _SingletonQuerysetMixin:
return SiteConfiguration.get_solo()
@extend_schema_view(
list=extend_schema(tags=["configuration"], summary="List site configuration (admin)"),
retrieve=extend_schema(tags=["configuration"], summary="Retrieve site configuration (admin)"),
create=extend_schema(tags=["configuration"], summary="Create site configuration (admin)"),
partial_update=extend_schema(tags=["configuration"], summary="Update site configuration (admin)"),
update=extend_schema(tags=["configuration"], summary="Replace site configuration (admin)"),
destroy=extend_schema(tags=["configuration"], summary="Delete site configuration (admin)"),
)
class SiteConfigurationAdminViewSet(_SingletonQuerysetMixin, viewsets.ModelViewSet):
permission_classes = [IsAdminUser]
serializer_class = SiteConfigurationAdminSerializer
@extend_schema_view(
list=extend_schema(tags=["configuration", "public"], summary="List site configuration (public)"),
retrieve=extend_schema(tags=["configuration", "public"], summary="Retrieve site configuration (public)"),
)
class SiteConfigurationPublicViewSet(_SingletonQuerysetMixin, viewsets.ReadOnlyModelViewSet):
permission_classes = [AllowAny]
serializer_class = SiteConfigurationPublicSerializer

View File

@@ -65,7 +65,7 @@ class CreatePaymentView(APIView):
permission_classes = [permissions.IsAuthenticated]
@extend_schema(
tags=["GoPay"],
tags=["gopay"],
operation_id="gopay_create_payment",
summary="Vytvořit platbu (minimální vstup)",
description=(
@@ -146,7 +146,7 @@ class PaymentStatusView(APIView):
permission_classes = [permissions.IsAuthenticated]
@extend_schema(
tags=["GoPay"],
tags=["gopay"],
operation_id="gopay_get_status",
summary="Získat stav platby",
parameters=[
@@ -202,7 +202,7 @@ class RefundPaymentView(APIView):
permission_classes = [permissions.IsAuthenticated]
@extend_schema(
tags=["GoPay"],
tags=["gopay"],
operation_id="gopay_refund_payment",
summary="Refundovat platbu",
parameters=[

View File

@@ -18,13 +18,13 @@ from .serializers import (
@extend_schema_view(
list=extend_schema(
tags=["Packeta-Shipment"],
tags=["zasilkovna"],
summary="Hromadný shipment",
description="Returns a paginated list of Packeta (Zásilkovna) shipments.",
responses=ZasilkovnaShipmentSerializer,
),
retrieve=extend_schema(
tags=["Packeta-Shipment"],
tags=["zasilkovna"],
summary="Detail hromadné zásilky",
description="Returns detail for a single shipment.",
responses=ZasilkovnaShipmentSerializer,
@@ -42,7 +42,7 @@ class ZasilkovnaShipmentViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin
@extend_schema_view(
retrieve=extend_schema(
tags=["Packet"],
tags=["zasilkovna"],
summary="Packet",
description="#TODO: Popis endpointu",
responses={200: ZasilkovnaPacketSerializer},
@@ -53,7 +53,7 @@ class ZasilkovnaPacketViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet
serializer_class = ZasilkovnaPacketSerializer
@extend_schema(
tags=["Packet"],
tags=["zasilkovna"],
summary="Get public tracking URL",
description="Returns the public Zásilkovna tracking URL derived from the packet's barcode.",
responses=OpenApiResponse(response=TrackingURLSerializer),
@@ -74,7 +74,7 @@ class ZasilkovnaPacketViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet
#HOTOVO
@extend_schema(
tags=["Packet"],
tags=["zasilkovna"],
summary="Order shipping",
description=(
"Objedná přepravu přes API Packety,"
@@ -96,7 +96,7 @@ class ZasilkovnaPacketViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet
#HOTOVO
@extend_schema(
tags=["Packet"],
tags=["zasilkovna"],
summary="Cancel packet",
description=(
"Cancels the packet through the Packeta API and updates its state to CANCELED. "
@@ -118,7 +118,7 @@ class ZasilkovnaPacketViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet
#TODO: dodělat/domluvit se
@extend_schema(
tags=["Packet"],
tags=["zasilkovna"],
summary="Get widget for user, to select pickup point.",
description=(
"Returns HTML widget for user to select pickup point. "

View File

@@ -816,7 +816,9 @@ SPECTACULAR_DEFAULTS: Dict[str, Any] = {
# enum name overrides. dict with keys "YourEnum" and their choice values "field.choices"
# e.g. {'SomeEnum': ['A', 'B'], 'OtherEnum': 'import.path.to.choices'}
'ENUM_NAME_OVERRIDES': {},
'ENUM_NAME_OVERRIDES': {
'OrderStatusEnum': 'commerce.models.Order.OrderStatus.choices',
},
# Adds "blank" and "null" enum choices where appropriate. disable on client generation issues
'ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE': True,

View File

@@ -91,7 +91,7 @@ def choices(request):
@extend_schema(
tags=["Testing"],
tags=["core", "testing"],
description="Testovací endpoint pro odeslání testovacího emailu.",
parameters=[
OpenApiParameter(