Add initial implementations for forms and organization apps with serializers, factories, and admin configurations
Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
This commit is contained in:
3
src/core/__init__.py
Normal file
3
src/core/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .celery import app as celery_app
|
||||
|
||||
__all__ = ("celery_app",)
|
||||
33
src/core/api_v1_urls.py
Normal file
33
src/core/api_v1_urls.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
API v1 URL configuration.
|
||||
|
||||
Все API эндпоинты версионированы под /api/v1/
|
||||
"""
|
||||
|
||||
from apps.core.views import (
|
||||
BackgroundJobListView,
|
||||
BackgroundJobStatusView,
|
||||
BackgroundJobStreamView,
|
||||
)
|
||||
from django.urls import include, path
|
||||
|
||||
app_name = "api_v1"
|
||||
|
||||
jobs_urlpatterns = [
|
||||
path("", BackgroundJobListView.as_view(), name="job-list"),
|
||||
path("<str:task_id>/stream/", BackgroundJobStreamView.as_view(), name="job-stream"),
|
||||
path("<str:task_id>/", BackgroundJobStatusView.as_view(), name="job-status"),
|
||||
]
|
||||
|
||||
urlpatterns = [
|
||||
path("users/", include("apps.user.urls")),
|
||||
path("jobs/", include((jobs_urlpatterns, "jobs"))),
|
||||
path("organizations/", include("apps.organization.urls")),
|
||||
path("registers/", include("apps.registers.urls")),
|
||||
path("forms/f1/", include("apps.form_1.urls")),
|
||||
path("forms/f2/", include("apps.form_2.urls")),
|
||||
path("forms/f3/", include("apps.form_3.urls")),
|
||||
path("forms/f4/", include("apps.form_4.urls")),
|
||||
path("forms/f5/", include("apps.form_5.urls")),
|
||||
path("forms/f6/", include("apps.form_6.urls")),
|
||||
]
|
||||
18
src/core/asgi.py
Normal file
18
src/core/asgi.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
ASGI config for the project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from apps.core.startup_checks import run_startup_checks
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.production")
|
||||
run_startup_checks(component="asgi")
|
||||
|
||||
application = get_asgi_application()
|
||||
54
src/core/celery.py
Normal file
54
src/core/celery.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
Celery configuration for the project.
|
||||
|
||||
This module contains Celery configuration and task registration.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from apps.core.startup_checks import run_startup_checks
|
||||
from celery import Celery
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Set the Django settings module for the 'celery' program.
|
||||
if "DJANGO_SETTINGS_MODULE" not in os.environ:
|
||||
raise RuntimeError(
|
||||
"DJANGO_SETTINGS_MODULE is not set. "
|
||||
"Export it explicitly before starting Celery "
|
||||
"(e.g., settings.production or settings.dev)."
|
||||
)
|
||||
|
||||
|
||||
def _is_celery_runtime() -> bool:
|
||||
"""True when current process is an actual Celery runtime command."""
|
||||
argv = " ".join(sys.argv).lower()
|
||||
return "celery" in argv and (
|
||||
" worker" in argv or " beat" in argv or " flower" in argv
|
||||
)
|
||||
|
||||
|
||||
if _is_celery_runtime():
|
||||
run_startup_checks(component="celery")
|
||||
|
||||
app = Celery("project")
|
||||
|
||||
# Using a string here means the worker doesn't have to serialize
|
||||
# the configuration object to child processes.
|
||||
# - namespace='CELERY' means all celery-related configuration keys
|
||||
# should have a `CELERY_` prefix.
|
||||
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||
|
||||
# Load task modules from all registered Django apps.
|
||||
app.autodiscover_tasks()
|
||||
|
||||
app.conf.beat_schedule = {}
|
||||
|
||||
app.conf.timezone = "Europe/Moscow"
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
def debug_task(self):
|
||||
print(f"Request: {self.request!r}")
|
||||
49
src/core/urls.py
Normal file
49
src/core/urls.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
URL Configuration for the project.
|
||||
|
||||
The `urlpatterns` list routes URLs to views.
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
from apps.core.openapi import (
|
||||
OPENAPI_PROJECT_DESCRIPTION,
|
||||
OPENAPI_PROJECT_TITLE,
|
||||
RussianTagSchemaGenerator,
|
||||
)
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.views import get_schema_view
|
||||
from rest_framework import permissions
|
||||
|
||||
# Swagger schema view
|
||||
schema_view = get_schema_view(
|
||||
openapi.Info(
|
||||
title=OPENAPI_PROJECT_TITLE,
|
||||
default_version="v1",
|
||||
description=OPENAPI_PROJECT_DESCRIPTION,
|
||||
contact=openapi.Contact(email="contact@state-corp.local"),
|
||||
license=openapi.License(name="BSD License"),
|
||||
),
|
||||
public=True,
|
||||
generator_class=RussianTagSchemaGenerator,
|
||||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path(
|
||||
"",
|
||||
schema_view.with_ui("swagger", cache_timeout=0),
|
||||
name="schema-swagger-ui",
|
||||
),
|
||||
path("admin/", admin.site.urls),
|
||||
path("health/", include("apps.core.urls")),
|
||||
path("api/v1/", include("core.api_v1_urls", namespace="api_v1")),
|
||||
path("auth/", include("rest_framework.urls")),
|
||||
]
|
||||
|
||||
# Serve media files in development
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
18
src/core/wsgi.py
Normal file
18
src/core/wsgi.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
WSGI config for the project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from apps.core.startup_checks import run_startup_checks
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev")
|
||||
run_startup_checks(component="wsgi")
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user