Backend (Django 4.2 + DRF): - accounts: phone OTP login, JWT, profile, addresses - catalog: categories, products, images, filters, search, hits/new/related - orders: creation with Idempotency-Key, stock reservation, status history, cancel - loyalty: bonus accounts, promo codes, gift certificates - payments: payment records and YooKassa webhook handling - content: static pages, banners, site settings - integration: 1C exchange (catalog sync, order push via outbox, statuses, bonuses) - common: error envelope, pagination, request-id, integration auth, admin dashboard Infrastructure: Dockerfile, docker-compose (Postgres, Redis, Celery worker/beat, Nginx), requirements split by environment, OpenAPI contracts for site and 1C, architecture doc. Tests: 22 pytest cases covering catalog, orders, idempotency, OTP, integration.
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
from rest_framework import serializers
|
|
|
|
from .models import Banner, SiteSettings, StaticPage
|
|
|
|
|
|
class SiteSettingsSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = SiteSettings
|
|
fields = [
|
|
"site_name",
|
|
"phone",
|
|
"email",
|
|
"address",
|
|
"working_hours",
|
|
"telegram_url",
|
|
"vk_url",
|
|
"whatsapp_url",
|
|
"free_delivery_threshold",
|
|
"default_delivery_cost",
|
|
"bonus_accrual_percent",
|
|
"bonus_max_payment_percent",
|
|
"bonus_ttl_days",
|
|
"privacy_policy_url",
|
|
"offer_url",
|
|
"updated_at",
|
|
]
|
|
read_only_fields = ["updated_at"]
|
|
|
|
|
|
class StaticPageSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = StaticPage
|
|
fields = [
|
|
"slug",
|
|
"title",
|
|
"content",
|
|
"seo_title",
|
|
"seo_description",
|
|
"updated_at",
|
|
]
|
|
read_only_fields = ["updated_at"]
|
|
|
|
|
|
class BannerSerializer(serializers.ModelSerializer):
|
|
position_display = serializers.CharField(
|
|
source="get_position_display", read_only=True
|
|
)
|
|
|
|
class Meta:
|
|
model = Banner
|
|
fields = [
|
|
"id",
|
|
"title",
|
|
"image_url",
|
|
"link_url",
|
|
"position",
|
|
"position_display",
|
|
"sort_order",
|
|
"starts_at",
|
|
"ends_at",
|
|
]
|