From 4c582cf1f37627c48e2b97a59f83d0663a045899 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Sat, 8 Feb 2025 20:19:59 +0330 Subject: [PATCH] remove setting and manage.py settings --- backend/core/settings.py | 437 --------------------------------------- backend/manage.py | 22 -- 2 files changed, 459 deletions(-) delete mode 100644 backend/core/settings.py diff --git a/backend/core/settings.py b/backend/core/settings.py deleted file mode 100644 index 3dcb3f1..0000000 --- a/backend/core/settings.py +++ /dev/null @@ -1,437 +0,0 @@ -from dotenv import load_dotenv -# from http.cookiejar import debug -from pathlib import Path -from datetime import timedelta -import os -from django.templatetags.static import static -from django.urls import reverse_lazy -from django.utils.translation import gettext_lazy as _ - -# TODO CREATE A ENV WITH THIS NAME -### keep the .env name to .env.local if you want to change this name you should change it in here too when you load this env -load_dotenv(".env.local") - -DOMAIN = os.getenv("DOMAIN") -API_DOMAIN = os.getenv("API_DOMAIN") -OPENAI_API_KEY = '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' -# TODO update telegram bot token -TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN") - -# TODO update email bullshit -EMAIL_BACKEND = os.getenv("EMAIL_BACKEND") -EMAIL_HOST = os.getenv("EMAIL_HOST") -EMAIL_PORT = 587 -EMAIL_USE_TLS = True -EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER") -EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD") -DEFAULT_FROM_EMAIL = os.getenv("SECRET_KEY") - -SECRET_KEY = os.getenv("SECRET_KEY") -DEBUG = True -# in production lists of allowed hosts and allowed orgins will genrate -# in development every host and orgin will be true -# in prodcution it will use the postgres info you enterd in .env.local -# in development it will use the sqlite -BASE_DIR = Path(__file__).resolve().parent.parent -if DEBUG: - ALLOWED_HOSTS = ['127.0.0.1', 'localhost', DOMAIN, API_DOMAIN] - CSRF_TRUSTED_ORIGINS = [ - f"https://{DOMAIN}", - f"http://{DOMAIN}", - f"https://{API_DOMAIN}", - f"http://{API_DOMAIN}", - ] - # CORS_ALLOWED_ORIGINS = [f"https://{API_DOMAIN}", f"http://{API_DOMAIN}", - # f"http://{DOMAIN}", f"https://{DOMAIN}", ] - # import re - # CORS_ALLOWED_ORIGIN_REGEXES = [ - # re.compile(r'^https?://(?:\w+\.)?{}$'.format(re.escape(API_DOMAIN))), - # re.compile(r'^https?://(?:\w+\.)?{}$'.format(re.escape(DOMAIN))), - # re.compile(r'^https?://(?:\w+\.)?localhost:\d+$'), - # re.compile(r'^https?://(?:\w+\.)?127\.0\.0\.1:\d+$'), - # ] - - - CORS_ALLOW_ALL_ORIGINS = True - # database postgres - DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': os.getenv("DB_NAME"), - 'USER': os.getenv("DB_USER"), - 'PASSWORD': os.getenv("DB_PASSWORD"), - 'HOST': os.getenv("DB_HOST"), - 'PORT': os.getenv("DB_PORT"), - } - } -else: - CORS_ALLOW_ALL_ORIGINS = True - # sqlite database - DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - } - } - - - -# Application definition - -INSTALLED_APPS = [ - # unfold theme - "unfold", - "unfold.contrib.filters", - "unfold.contrib.forms", - "unfold.contrib.inlines", - "unfold.contrib.import_export", - "unfold.contrib.guardian", - "unfold.contrib.simple_history", - # django - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - # thired party apps - 'corsheaders', - 'rest_framework', - 'drf_spectacular', - 'django_cleanup.apps.CleanupConfig', - 'django_filters', - 'rest_framework_simplejwt', - 'rest_framework_simplejwt.token_blacklist', - 'rest_framework.authtoken', - 'import_export', - # custom apps - 'product', - 'account', - 'ticket', - 'chat', - 'order', - 'home', - 'blog', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - "whitenoise.middleware.WhiteNoiseMiddleware", - 'django.contrib.sessions.middleware.SessionMiddleware', - 'corsheaders.middleware.CorsMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = 'core.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [BASE_DIR / "templates"], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'core.wsgi.application' - - -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 = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_TZ = True - -MEDIA_URL = '/shop_media/' -MEDIA_ROOT = '/app/media' - -STATIC_URL = '/shop_static/' -STATIC_ROOT = '/app/static' - -STATICFILES_DIRS = [ - os.path.join(BASE_DIR, 'custom_static'), - BASE_DIR / "core" / "static" -] - -STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" - -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' - -# AUTH_USER_MODEL = 'accounts.User' - - -REST_FRAMEWORK = { - # 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'], - 'DEFAULT_RENDERER_CLASSES': [ - 'rest_framework.renderers.JSONRenderer', - 'rest_framework.renderers.BrowsableAPIRenderer', - - ], - 'DEFAULT_AUTHENTICATION_CLASSES': ( - - 'rest_framework_simplejwt.authentication.JWTAuthentication', - - ), - 'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema', - # 'DEFAULT_PERMISSION_CLASSES': [ - # 'rest_framework.permissions.IsAuthenticated', - # ], -} - -SIMPLE_JWT = { - 'ACCESS_TOKEN_LIFETIME': timedelta(days=1), - 'REFRESH_TOKEN_LIFETIME': timedelta(days=7), - 'ROTATE_REFRESH_TOKENS': True, - 'BLACKLIST_AFTER_ROTATION': True, -} - -SPECTACULAR_SETTINGS = { - 'TITLE': os.getenv("SITE_TITLE"), - 'DESCRIPTION': os.getenv("SITE_TITLE"), - 'VERSION': '1.0.0', - 'SERVE_INCLUDE_SCHEMA': False, - 'COMPONENT_SPLIT_REQUEST': True -} - -UNFOLD = { - "SITE_TITLE": os.getenv("SITE_TITLE"), - "SITE_HEADER": os.getenv("SITE_HEADER"), - "SITE_URL": DOMAIN, - "THEME": 'dark', - "SITE_SYMBOL": "settings", - "DASHBOARD_CALLBACK": "core.views.dashboard_callback", - "SITE_FAVICONS": [ - { - "rel": "icon", - "sizes": "32x32", - "type": "image/svg+xml", - "href": lambda request: static("favicon.svg"), - }, - ], - "LOGIN": { - "image": lambda request: static("favicon.png"), - }, - - - "BORDER_RADIUS": "8px", - "SHOW_HISTORY": True, - "SHOW_VIEW_ON_SITE": True, - "ENVIRONMENT": "core.settings.environment_callback", - -"COLORS": { - "base": { - "50": "250 250 250", - "100": "245 245 245", - "200": "229 229 229", - "300": "212 212 212", - "400": "163 163 163", - "500": "115 115 115", - "600": "82 82 82", - "700": "64 64 64", - "800": "38 38 38", - "900": "23 23 23", - "950": "10 10 10" - }, - "primary": { - "50": "240 253 244", - "100": "220 252 231", - "200": "187 247 208", - "300": "134 239 172", - "400": "74 222 128", - "500": "34 197 94", - "600": "22 163 74", - "700": "21 128 61", - "800": "22 101 52", - "900": "20 83 45", - "950": "5 46 22" - }, - "font": { - "subtle-light": "var(--color-base-500)", # text-base-500 - "subtle-dark": "var(--color-base-400)", # text-base-400 - "default-light": "var(--color-base-600)", # text-base-600 - "default-dark": "var(--color-base-300)", # text-base-300 - "important-light": "var(--color-base-900)", # text-base-900 - "important-dark": "var(--color-base-100)", # text-base-100 - }, - }, - "EXTENSIONS": { - "modeltranslation": { - "flags": { - "en": "🇬🇧", - }, - }, - }, - - "SIDEBAR": { - "show_search": True, - "show_all_applications": True, - "navigation": [ - { - - "separator": False, # Top border - "collapsible": False, # Collapsible group of links - "items": [ - { - "title": _("داشبرد ادمین"), - "icon": "dashboard", - "link": reverse_lazy("admin:index"), - }, - { - "title": _("سفارشات"), - "icon": "shopping_cart", - "link": reverse_lazy("admin:order_ordermodel_changelist"), - "badge": "utils.admin.admin_pending_count", - }, - ], - }, - - - - { - "title": _("محصولات فروشگاه"), - "separator": True, - "collapsible": False, - "items": [ - { - "title": _("محصولات"), - "icon": "redeem", - "link": reverse_lazy("admin:product_productmodel_changelist"), - }, - - { - "title": _("نظرات"), - "icon": "chat", - "link": reverse_lazy("admin:product_commentmodel_changelist"), - }, - { - "title": _("قیمت دلار"), - "icon": "payments", - "link": reverse_lazy("admin:product_dollormodel_changelist"), - "badge": "utils.admin.dollor_price", - }, - - ], - }, - - - { - "title": _("سکشن دسته بندی"), - "separator": True, - "collapsible": False, - "items": [ - - { - "title": _("دسته بندی"), - "icon": "category", - "link": reverse_lazy("admin:product_maincategorymodel_changelist"), - }, - { - "title": _("زیر دسته بندی"), - "icon": "category", - "link": reverse_lazy("admin:product_subcategorymodel_changelist"), - } - - ], - }, - { - "title": _("سکشن های نمایشی"), - "separator": True, - "collapsible": True, - "items": [ - - { - "title": _("اسلاید ها"), - "icon": "slide_library", - "link": reverse_lazy("admin:home_slidermodel_changelist"), - }, - { - "title": _("عکس مقایسه"), - "icon": "compare", - "link": reverse_lazy("admin:home_homeimagemodel_changelist"), - } - , - { - "title": _("مقالات و بلاگ ها"), - "icon": "newsmode", - "link": reverse_lazy("admin:blog_blogmodel_changelist"), - } - - ], - }, - - { - "title": _("کاربران و مشتریان"), - "separator": True, - "collapsible": True, - "items": [ - - { - "title": _("کاربران"), - "icon": "person", - "link": reverse_lazy("admin:account_user_changelist"), - },{ - "title": _("چت محصول"), - "icon": "chat", - "link": reverse_lazy("admin:chat_productchatmodel_changelist"), - }, - { - "title": _("ادرس ها"), - "icon": "contact_mail", - "link": reverse_lazy("admin:account_useraddressmodel_changelist"), - }, - - ], - }, - - { - "title": _("پشتیبانی و تیکت"), - "separator": True, - "collapsible": True, - "items": [ - - { - "title": _("تیکت"), - "icon": "confirmation_number", - "link": reverse_lazy("admin:ticket_ticket_changelist"), - }, - - ], - }, - - - ], - }, -} - -AUTH_USER_MODEL = 'account.User' -def environment_callback(request): - return ["نسخه ی توسعه", "success"] - diff --git a/backend/manage.py b/backend/manage.py index 6646512..4a3b639 100755 --- a/backend/manage.py +++ b/backend/manage.py @@ -1,25 +1,3 @@ -# #!/usr/bin/env python -# """Django's command-line utility for administrative tasks.""" -# import os -# import sys - - -# def main(): -# """Run administrative tasks.""" -# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') -# try: -# from django.core.management import execute_from_command_line -# except ImportError as exc: -# raise ImportError( -# "Couldn't import Django. Are you sure it's installed and " -# "available on your PYTHONPATH environment variable? Did you " -# "forget to activate a virtual environment?" -# ) from exc -# execute_from_command_line(sys.argv) - - -# if __name__ == '__main__': -# main() import os import sys