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,46 @@
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
|
||||
from .models import Banner, SiteSettings, StaticPage
|
||||
from .serializers import BannerSerializer, SiteSettingsSerializer, StaticPageSerializer
|
||||
|
||||
|
||||
class SiteSettingsView(APIView):
|
||||
"""Public store settings used by the storefront."""
|
||||
|
||||
permission_classes = [AllowAny]
|
||||
serializer_class = SiteSettingsSerializer
|
||||
|
||||
def get(self, request):
|
||||
settings_obj = SiteSettings.load()
|
||||
return Response(SiteSettingsSerializer(settings_obj).data)
|
||||
|
||||
|
||||
class StaticPageViewSet(ReadOnlyModelViewSet):
|
||||
queryset = StaticPage.objects.filter(is_published=True)
|
||||
serializer_class = StaticPageSerializer
|
||||
lookup_field = "slug"
|
||||
permission_classes = [AllowAny]
|
||||
pagination_class = None
|
||||
|
||||
|
||||
class BannerViewSet(ReadOnlyModelViewSet):
|
||||
serializer_class = BannerSerializer
|
||||
permission_classes = [AllowAny]
|
||||
pagination_class = None
|
||||
|
||||
def get_queryset(self):
|
||||
now = timezone.now()
|
||||
queryset = (
|
||||
Banner.objects.filter(is_active=True)
|
||||
.filter(Q(starts_at__isnull=True) | Q(starts_at__lte=now))
|
||||
.filter(Q(ends_at__isnull=True) | Q(ends_at__gte=now))
|
||||
)
|
||||
position = self.request.query_params.get("position")
|
||||
if position:
|
||||
queryset = queryset.filter(position=position)
|
||||
return queryset
|
||||
Reference in new issue
Block a user