initial commit

This commit is contained in:
behruz-dev
2025-08-28 13:05:11 +05:00
commit 8ac8fd8787
58 changed files with 783 additions and 0 deletions

0
config/__init__.py Normal file
View File

16
config/asgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
ASGI config for config 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/5.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.base')
application = get_asgi_application()

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

@@ -0,0 +1,6 @@
from .rest_framework import *
from .cors import *
from .jwt import *
from .logs import *
from .swagger import *
from .redis import *

9
config/conf/cors.py Normal file
View File

@@ -0,0 +1,9 @@
CORS_ALLOWED_ORIGINS = [
"http://localhost:5173",
"http://127.0.0.1:5173",
]
CSRF_TRUSTED_ORIGINS = [
'http://localhost:8001',
'http://127.0.0.1:8001',
]

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

@@ -0,0 +1,10 @@
from datetime import timedelta
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(days=30),
"REFRESH_TOKEN_LIFETIME": timedelta(days=365),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True,
"UPDATE_LAST_LOGIN": True,
}

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

24
config/conf/redis.py Normal file
View File

@@ -0,0 +1,24 @@
CACHES = {
"default": {
"BACKEND": 'django_redis.cache.RedisCache',
"LOCATION": 'redis://redis:6379',
"TIMEOUT": 300,
},
}
CACHE_MIDDLEWARE_SECONDS = 300
CACHEOPS_REDIS = 'redis://redis:6379'
CACHEOPS_DEFAULTS = {
"timeout": 300,
}
CACHEOPS = {
"accounts.*": {
"ops": "all",
"timeout": 60 * 5,
},
}
CACHEOPS_DEGRADE_ON_FAILURE = True
CACHEOPS_ENABLED = False

View File

@@ -0,0 +1,9 @@
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework_simplejwt.authentication.JWTAuthentication',
],
# 'DEFAULT_PAGINATION_CLASS': 'core.apps.shared.paginations.custom.CustomPageNumberPagination',
# 'PAGE_SIZE': 10
}

13
config/conf/swagger.py Normal file
View File

@@ -0,0 +1,13 @@
SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'Basic': {
'type': 'basic'
},
'Bearer': {
'type': 'apiKey',
'name': 'Authorization',
'in': 'header'
}
},
"USE_SESSION_AUTH": False
}

8
config/env.py Normal file
View File

@@ -0,0 +1,8 @@
import os, environ
environ.Env.read_env(os.path.join(".env"))
env = environ.Env(
)

99
config/settings/base.py Normal file
View File

@@ -0,0 +1,99 @@
from pathlib import Path
from config.env import env
BASE_DIR = Path(__file__).resolve().parent.parent.parent
SECRET_KEY = env.str('SECRET_KEY')
DEBUG = env.bool('DEBUG')
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'config.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': env.str('POSTGRES_DB'),
'USER': env.str('POSTGRES_USER'),
'PASSWORD': env.str('POSTGRES_PASSWORD'),
'HOST': env.str('POSTGRES_HOST'),
'PORT': env.str('POSTGRES_PORT'),
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'uz'
TIME_ZONE = 'Asia/Tashkent'
USE_I18N = True
USE_TZ = False
STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / 'resources/static'
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR / 'resources/media'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
from config.conf import *

0
config/settings/local.py Normal file
View File

0
config/settings/prod.py Normal file
View File

0
config/settings/test.py Normal file
View File

32
config/urls.py Normal file
View File

@@ -0,0 +1,32 @@
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from rest_framework.permissions import IsAdminUser
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(
title="Horeca 360 API",
default_version='v1',
description="Test description",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="xoliqberdiyevbehru12@gmail.com"),
license=openapi.License(name="Felix IT Solutions License"),
),
public=True,
permission_classes=[IsAdminUser]
)
urlpatterns = [
path('admin/', admin.site.urls),
path('', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

16
config/wsgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
WSGI config for config 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/5.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.base')
application = get_wsgi_application()