initial commit

This commit is contained in:
2025-08-05 10:26:39 +05:00
commit b7412bbef6
298 changed files with 10533 additions and 0 deletions

11
config/conf/__init__.py Normal file
View File

@@ -0,0 +1,11 @@
from .cache import * # noqa
from .celery import * # noqa
from .cron import * # noqa
from .jwt import * # noqa
from .logs import * # noqa
from .rest_framework import * # noqa
from .unfold import * # noqa
from .spectacular import * # noqa
from .storage import * # noqa

27
config/conf/apps.py Normal file
View File

@@ -0,0 +1,27 @@
from config.env import env
APPS = [
"cacheops",
"drf_spectacular",
"rest_framework",
"corsheaders",
"django_filters",
"django_redis",
"rest_framework_simplejwt",
"django_core",
'storages',
"core.apps.accounts.apps.AccountsConfig",
"core.apps.companies.apps.ModuleConfig",
"core.apps.contracts.apps.ModuleConfig",
"core.apps.banks.apps.ModuleConfig",
]
if env.str("PROJECT_ENV") == "debug":
APPS += [
"silk",
]

26
config/conf/cache.py Normal file
View File

@@ -0,0 +1,26 @@
from config.env import env
CACHES = {
"default": {
"BACKEND": env.str("CACHE_BACKEND"),
"LOCATION": env.str("REDIS_URL"),
"TIMEOUT": env.str("CACHE_TIMEOUT"),
},
}
CACHE_MIDDLEWARE_SECONDS = env("CACHE_TIMEOUT")
CACHEOPS_REDIS = env.str("REDIS_URL")
CACHEOPS_DEFAULTS = {
"timeout": env.str("CACHE_TIMEOUT"),
}
CACHEOPS = {
# !NOTE: api => "you app name"
# "api.*": {
# "ops": "all", # Barcha turdagi so'rovlarni keshga olish
# "timeout": 60 * 5, # 5 daqiqa davomida saqlash
# },
}
CACHEOPS_DEGRADE_ON_FAILURE = True
CACHEOPS_ENABLED = env.bool("CACHE_ENABLED", False)

7
config/conf/celery.py Normal file
View File

@@ -0,0 +1,7 @@
CELERY_BEAT_SCHEDULE = {
# "test": {
# "task": "core.apps.home.tasks.demo.add",
# "schedule": 5.0,
# "args": (1, 2)
# },
}

8
config/conf/channels.py Normal file
View File

@@ -0,0 +1,8 @@
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("redis", 6379)],
},
},
}

147
config/conf/ckeditor.py Normal file
View File

@@ -0,0 +1,147 @@
import os
from pathlib import Path
STATIC_URL = "/resources/static/"
MEDIA_URL = "/resources/media/"
MEDIA_ROOT = os.path.join(Path().parent.parent, "media")
customColorPalette = [
{"color": "hsl(4, 90%, 58%)", "label": "Red"},
{"color": "hsl(340, 82%, 52%)", "label": "Pink"},
{"color": "hsl(291, 64%, 42%)", "label": "Purple"},
{"color": "hsl(262, 52%, 47%)", "label": "Deep Purple"},
{"color": "hsl(231, 48%, 48%)", "label": "Indigo"},
{"color": "hsl(207, 90%, 54%)", "label": "Blue"},
]
CKEDITOR_5_CONFIGS = {
"default": {
"toolbar": [
"heading",
"|",
"bold",
"italic",
"link",
"bulletedList",
"numberedList",
"blockQuote",
"imageUpload",
],
},
"extends": {
"blockToolbar": [
"paragraph",
"heading1",
"heading2",
"heading3",
"|",
"bulletedList",
"numberedList",
"|",
"blockQuote",
],
"toolbar": [
"heading",
"|",
"outdent",
"indent",
"|",
"bold",
"italic",
"link",
"underline",
"strikethrough",
"code",
"subscript",
"superscript",
"highlight",
"|",
"codeBlock",
"sourceEditing",
"insertImage",
"bulletedList",
"numberedList",
"todoList",
"|",
"blockQuote",
"imageUpload",
"|",
"fontSize",
"fontFamily",
"fontColor",
"fontBackgroundColor",
"mediaEmbed",
"removeFormat",
"insertTable",
],
"image": {
"toolbar": [
"imageTextAlternative",
"|",
"imageStyle:alignLeft",
"imageStyle:alignRight",
"imageStyle:alignCenter",
"imageStyle:side",
"|",
],
"styles": [
"full",
"side",
"alignLeft",
"alignRight",
"alignCenter",
],
},
"table": {
"contentToolbar": [
"tableColumn",
"tableRow",
"mergeTableCells",
"tableProperties",
"tableCellProperties",
],
"tableProperties": {
"borderColors": customColorPalette,
"backgroundColors": customColorPalette,
},
"tableCellProperties": {
"borderColors": customColorPalette,
"backgroundColors": customColorPalette,
},
},
"heading": {
"options": [
{
"model": "paragraph",
"title": "Paragraph",
"class": "ck-heading_paragraph",
},
{
"model": "heading1",
"view": "h1",
"title": "Heading 1",
"class": "ck-heading_heading1",
},
{
"model": "heading2",
"view": "h2",
"title": "Heading 2",
"class": "ck-heading_heading2",
},
{
"model": "heading3",
"view": "h3",
"title": "Heading 3",
"class": "ck-heading_heading3",
},
]
},
},
"list": {
"properties": {
"styles": "true",
"startIndex": "true",
"reversed": "true",
}
},
}

0
config/conf/cron.py Normal file
View File

36
config/conf/jwt.py Normal file
View File

@@ -0,0 +1,36 @@
from datetime import timedelta
from config.env import env
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=60),
"REFRESH_TOKEN_LIFETIME": timedelta(days=30),
"ROTATE_REFRESH_TOKENS": False,
"BLACKLIST_AFTER_ROTATION": False,
"UPDATE_LAST_LOGIN": False,
"ALGORITHM": "HS256",
"SIGNING_KEY": env("DJANGO_SECRET_KEY"),
"VERIFYING_KEY": "",
"AUDIENCE": None,
"ISSUER": None,
"JSON_ENCODER": None,
"JWK_URL": None,
"LEEWAY": 0,
"AUTH_HEADER_TYPES": ("Bearer",),
"AUTH_HEADER_NAME": "HTTP_AUTHORIZATION",
"USER_ID_FIELD": "id",
"USER_ID_CLAIM": "user_id",
"AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",),
"TOKEN_TYPE_CLAIM": "token_type",
"TOKEN_USER_CLASS": "rest_framework_simplejwt.models.TokenUser",
"JTI_CLAIM": "jti",
"SLIDING_TOKEN_REFRESH_EXP_CLAIM": "refresh_exp",
"SLIDING_TOKEN_LIFETIME": timedelta(minutes=60),
"SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=30),
"TOKEN_OBTAIN_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainPairSerializer",
"TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSerializer",
"TOKEN_VERIFY_SERIALIZER": "rest_framework_simplejwt.serializers.TokenVerifySerializer",
"TOKEN_BLACKLIST_SERIALIZER": "rest_framework_simplejwt.serializers.TokenBlacklistSerializer",
"SLIDING_TOKEN_OBTAIN_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainSlidingSerializer",
"SLIDING_TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSlidingSerializer",
}

29
config/conf/logs.py Normal file
View File

@@ -0,0 +1,29 @@
# settings.py faylida
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"verbose": {
"format": "{levelname} {asctime} {module} {message}",
"style": "{",
},
},
"handlers": {
"daily_rotating_file": {
"level": "INFO",
"class": "logging.handlers.TimedRotatingFileHandler",
"filename": "resources/logs/django.log", # Fayl nomi (kunlik fayllar uchun avtomatik yoziladi)
"when": "midnight", # Har kecha log fayli yangilanadi
"backupCount": 30, # 30 kunlik loglar saqlanadi, 1 oydan keyin eski fayllar o'chiriladi
"formatter": "verbose",
},
},
"loggers": {
"django": {
"handlers": ["daily_rotating_file"],
"level": "INFO",
"propagate": True,
},
},
}

3
config/conf/modules.py Normal file
View File

@@ -0,0 +1,3 @@
MODULES = [
"core.apps.shared",
]

31
config/conf/navigation.py Normal file
View File

@@ -0,0 +1,31 @@
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _
PAGES = [
{
"seperator": False,
"items": [
{
"title": _("Home page"),
"icon": "home",
"link": reverse_lazy("admin:index"),
}
],
},
{
"title": _("Auth"),
"separator": True, # Top border
"items": [
{
"title": _("Users"),
"icon": "group",
"link": reverse_lazy("admin:http_user_changelist"),
},
{
"title": _("Group"),
"icon": "group",
"link": reverse_lazy("admin:auth_group_changelist"),
},
],
},
]

View File

@@ -0,0 +1,9 @@
from typing import Any, Union
REST_FRAMEWORK: Union[Any] = {
"DEFAULT_AUTHENTICATION_CLASSES": ("rest_framework_simplejwt.authentication.JWTAuthentication",),
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"],
"DEFAULT_PAGINATION_CLASS": "django_core.paginations.CustomPagination",
"PAGE_SIZE": 10,
}

View File

@@ -0,0 +1,32 @@
SPECTACULAR_SETTINGS = {
"TITLE": "Your Project API",
"DESCRIPTION": "Your project description",
"VERSION": "1.0.0",
"SERVE_INCLUDE_SCHEMA": False,
"CAMELIZE_NAMES": True,
"POSTPROCESSING_HOOKS": ["config.conf.spectacular.custom_postprocessing_hook"],
"COMPONENT_SPLIT_REQUEST": True,
}
def custom_postprocessing_hook(result, generator, request, public):
"""
Customizes the API schema to wrap all responses in a standard format.
"""
for path, methods in result.get("paths", {}).items():
for method, operation in methods.items():
if "responses" in operation:
for status_code, response in operation["responses"].items():
if "content" in response:
for content_type, content in response["content"].items():
# Wrap original schema
original_schema = content.get("schema", {})
response["content"][content_type]["schema"] = {
"type": "object",
"properties": {
"status": {"type": "boolean", "example": True},
"data": original_schema,
},
"required": ["status", "data"],
}
return result

23
config/conf/storage.py Normal file
View File

@@ -0,0 +1,23 @@
from config.env import env
from core.utils.storage import Storage
AWS_ACCESS_KEY_ID = env.str("STORAGE_ID")
AWS_SECRET_ACCESS_KEY = env.str("STORAGE_KEY")
AWS_S3_ENDPOINT_URL = env.str("STORAGE_URL")
AWS_S3_CUSTOM_DOMAIN = env.str("STORAGE_PATH")
AWS_S3_URL_PROTOCOL = env.str("STORAGE_PROTOCOL", "https:")
AWS_S3_FILE_OVERWRITE = False
default_storage = Storage(env.str("STORAGE_DEFAULT"), "default")
static_storage = Storage(env.str("STORAGE_STATIC"), "static")
STORAGES = {
"default": {
"BACKEND": default_storage.get_backend(),
"OPTIONS": default_storage.get_options(),
},
"staticfiles": {
"BACKEND": static_storage.get_backend(),
"OPTIONS": static_storage.get_options(),
},
}

41
config/conf/unfold.py Normal file
View File

@@ -0,0 +1,41 @@
from . import navigation
UNFOLD = {
"DASHBOARD_CALLBACK": "django_core.views.dashboard_callback",
"SITE_TITLE": None,
"SHOW_LANGUAGES": True,
"SITE_HEADER": None,
"SITE_URL": "/",
"SITE_SYMBOL": "speed", # symbol from icon set
"SHOW_HISTORY": True, # show/hide "History" button, default: True
"SHOW_VIEW_ON_SITE": True,
"COLORS": {
"primary": {
"50": "220 255 230",
"100": "190 255 200",
"200": "160 255 170",
"300": "130 255 140",
"400": "100 255 110",
"500": "70 255 80",
"600": "50 225 70",
"700": "40 195 60",
"800": "30 165 50",
"900": "20 135 40",
"950": "10 105 30",
},
},
"EXTENSIONS": {
"modeltranslation": {
"flags": {
"en": "🇬🇧",
"uz": "🇺🇿",
"ru": "🇷🇺",
},
},
},
"SIDEBAR": {
"show_search": True, # Search in applications and models names
"show_all_applications": True,
# "navigation": navigation.PAGES, # Pagelarni qo'lda qo'shish
},
}