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.
65 lines
1.6 KiB
Python
65 lines
1.6 KiB
Python
from rest_framework import serializers
|
|
|
|
from .models import Address, User
|
|
|
|
|
|
class OtpRequestSerializer(serializers.Serializer):
|
|
phone = serializers.CharField(max_length=20)
|
|
|
|
|
|
class OtpVerifySerializer(serializers.Serializer):
|
|
phone = serializers.CharField(max_length=20)
|
|
code = serializers.CharField(max_length=8)
|
|
|
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
|
full_name = serializers.CharField(read_only=True)
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = [
|
|
"id",
|
|
"phone",
|
|
"email",
|
|
"first_name",
|
|
"last_name",
|
|
"middle_name",
|
|
"full_name",
|
|
"date_joined",
|
|
]
|
|
read_only_fields = ["id", "phone", "date_joined"]
|
|
|
|
|
|
class ProfileUpdateSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = User
|
|
fields = ["email", "first_name", "last_name", "middle_name"]
|
|
|
|
|
|
class AddressSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Address
|
|
fields = [
|
|
"id",
|
|
"title",
|
|
"city",
|
|
"street",
|
|
"house",
|
|
"apartment",
|
|
"postal_code",
|
|
"entrance",
|
|
"floor",
|
|
"intercom",
|
|
"is_default",
|
|
"created_at",
|
|
"updated_at",
|
|
]
|
|
read_only_fields = ["id", "created_at", "updated_at"]
|
|
|
|
|
|
class PasswordSetSerializer(serializers.Serializer):
|
|
current_password = serializers.CharField(
|
|
required=False, allow_blank=True, write_only=True
|
|
)
|
|
new_password = serializers.CharField(min_length=8, write_only=True)
|