Add Django backend, 1C integration, deploy config and API docs
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.
This commit is contained in:
1 parent
5f8d37357d
commit
756f40353b
130 files changed
+10066
No files matched your search
@@ -0,0 +1,108 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db import models
|
||||
|
||||
from apps.common.models import TimeStampedModel
|
||||
|
||||
|
||||
class SiteSettings(models.Model):
|
||||
"""Singleton with store-wide settings editable from the admin."""
|
||||
|
||||
site_name = models.CharField("название сайта", max_length=255, default="HOMM")
|
||||
phone = models.CharField("телефон", max_length=32, blank=True)
|
||||
email = models.EmailField("email", blank=True)
|
||||
address = models.CharField("адрес", max_length=500, blank=True)
|
||||
working_hours = models.CharField("часы работы", max_length=255, blank=True)
|
||||
|
||||
telegram_url = models.URLField("Telegram", blank=True)
|
||||
vk_url = models.URLField("ВКонтакте", blank=True)
|
||||
whatsapp_url = models.URLField("WhatsApp", blank=True)
|
||||
|
||||
free_delivery_threshold = models.DecimalField(
|
||||
"бесплатная доставка от", max_digits=12, decimal_places=2, default=Decimal("0")
|
||||
)
|
||||
default_delivery_cost = models.DecimalField(
|
||||
"стоимость доставки", max_digits=12, decimal_places=2, default=Decimal("0")
|
||||
)
|
||||
|
||||
bonus_accrual_percent = models.DecimalField(
|
||||
"процент начисления бонусов", max_digits=5, decimal_places=2, default=Decimal("0")
|
||||
)
|
||||
bonus_max_payment_percent = models.DecimalField(
|
||||
"максимум оплаты бонусами, %", max_digits=5, decimal_places=2, default=Decimal("0")
|
||||
)
|
||||
bonus_ttl_days = models.PositiveIntegerField("срок жизни бонусов, дней", default=365)
|
||||
|
||||
privacy_policy_url = models.URLField("политика конфиденциальности", blank=True)
|
||||
offer_url = models.URLField("публичная оферта", blank=True)
|
||||
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "content_site_settings"
|
||||
verbose_name = "настройки сайта"
|
||||
verbose_name_plural = "настройки сайта"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "Настройки сайта"
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.pk = 1
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def load(cls) -> "SiteSettings":
|
||||
obj, _ = cls.objects.get_or_create(pk=1)
|
||||
return obj
|
||||
|
||||
|
||||
class StaticPage(TimeStampedModel):
|
||||
slug = models.SlugField("адрес", max_length=255, unique=True)
|
||||
title = models.CharField("заголовок", max_length=255)
|
||||
content = models.TextField("содержимое", blank=True)
|
||||
seo_title = models.CharField("SEO title", max_length=255, blank=True)
|
||||
seo_description = models.CharField("SEO description", max_length=500, blank=True)
|
||||
is_published = models.BooleanField("опубликована", default=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "content_static_page"
|
||||
verbose_name = "статическая страница"
|
||||
verbose_name_plural = "статические страницы"
|
||||
ordering = ["title"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.title
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.slug:
|
||||
from apps.common.utils import make_slug
|
||||
|
||||
self.slug = make_slug(self.title)
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class Banner(TimeStampedModel):
|
||||
class Position(models.TextChoices):
|
||||
HOME_TOP = "home_top", "Главная — верх"
|
||||
HOME_MIDDLE = "home_middle", "Главная — середина"
|
||||
CATEGORY = "category", "Категория"
|
||||
|
||||
title = models.CharField("название", max_length=255)
|
||||
image_url = models.URLField("изображение", max_length=1000)
|
||||
link_url = models.URLField("ссылка", max_length=1000, blank=True)
|
||||
position = models.CharField(
|
||||
"позиция", max_length=20, choices=Position.choices, default=Position.HOME_TOP
|
||||
)
|
||||
is_active = models.BooleanField("активен", default=True)
|
||||
sort_order = models.IntegerField("порядок", default=0)
|
||||
starts_at = models.DateTimeField("начало показа", null=True, blank=True)
|
||||
ends_at = models.DateTimeField("конец показа", null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "content_banner"
|
||||
verbose_name = "баннер"
|
||||
verbose_name_plural = "баннеры"
|
||||
ordering = ["sort_order", "-created_at"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.title
|
||||
Reference in new issue
Block a user