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:
@@ -0,0 +1,54 @@
|
||||
from rest_framework import serializers
|
||||
from .models import ShopConfiguration
|
||||
|
||||
|
||||
class ShopConfigurationAdminSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ShopConfiguration
|
||||
fields = [
|
||||
"id",
|
||||
"name",
|
||||
"logo",
|
||||
"favicon",
|
||||
"contact_email",
|
||||
"contact_phone",
|
||||
"contact_address",
|
||||
"opening_hours",
|
||||
"facebook_url",
|
||||
"instagram_url",
|
||||
"youtube_url",
|
||||
"tiktok_url",
|
||||
"whatsapp_number",
|
||||
"zasilkovna_shipping_price",
|
||||
"zasilkovna_api_key",
|
||||
"zasilkovna_api_password",
|
||||
"free_shipping_over",
|
||||
"multiplying_coupons",
|
||||
"addition_of_coupons_amount",
|
||||
"currency",
|
||||
]
|
||||
|
||||
|
||||
class ShopConfigurationPublicSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ShopConfiguration
|
||||
# Expose only non-sensitive fields
|
||||
fields = [
|
||||
"id",
|
||||
"name",
|
||||
"logo",
|
||||
"favicon",
|
||||
"contact_email",
|
||||
"contact_phone",
|
||||
"contact_address",
|
||||
"opening_hours",
|
||||
"facebook_url",
|
||||
"instagram_url",
|
||||
"youtube_url",
|
||||
"tiktok_url",
|
||||
# Exclude API keys/passwords
|
||||
"zasilkovna_shipping_price",
|
||||
"free_shipping_over",
|
||||
"currency",
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user