config.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. import os
  2. from pathlib import Path
  3. from django.contrib.messages import constants as message_constants
  4. class ConfigDjango:
  5. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  6. BASE_DIR = Path(__file__).resolve().parent.parent
  7. # SECURITY WARNING: keep the secret key used in production secret!
  8. SECRET_KEY = 'fgknfdlgndfskgnsdlfgnksdl;gnsegbwelgbnajl*u$qkt7j-b)7t1iq'
  9. # SECURITY WARNING: don't run with debug turned on in production!
  10. DEBUG = True
  11. CSRF_TRUSTED_ORIGINS = ["https://*.sharix-app.org"]
  12. ALLOWED_HOSTS = ['testopen.sharix-app.org']
  13. INTERNAL_IPS = ["127.0.0.1"]
  14. # Application definition
  15. INSTALLED_APPS = [
  16. 'jazzmin',
  17. 'django.contrib.admin',
  18. 'django.contrib.auth',
  19. 'django.contrib.contenttypes',
  20. 'django.contrib.sessions',
  21. 'django.contrib.messages',
  22. 'django.contrib.staticfiles',
  23. 'SharixAdmin.apps.SharixadminConfig',
  24. 'tickets.apps.TicketsConfig',
  25. 'dbsynce.apps.MetaservicesyncedConfig',
  26. 'django_tables2',
  27. "django.contrib.sites",
  28. "django.contrib.flatpages",
  29. "django.contrib.admindocs",
  30. "django_extensions",
  31. 'rest_framework',
  32. 'rest_framework.authtoken',
  33. 'djoser',
  34. 'schema_graph',
  35. 'drf_yasg',
  36. 'django_spaghetti',
  37. 'debug_toolbar',
  38. ]
  39. MIDDLEWARE = [
  40. 'django.middleware.security.SecurityMiddleware',
  41. 'django.contrib.sessions.middleware.SessionMiddleware',
  42. 'django.middleware.common.CommonMiddleware',
  43. 'django.middleware.csrf.CsrfViewMiddleware',
  44. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  45. 'django.contrib.messages.middleware.MessageMiddleware',
  46. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  47. 'django.contrib.admindocs.middleware.XViewMiddleware',
  48. "debug_toolbar.middleware.DebugToolbarMiddleware",
  49. ]
  50. ROOT_URLCONF = "core.urls"
  51. SESSION_EXPIRE_AT_BROWSER_CLOSE = False
  52. SESSION_SECURITY_WARN_AFTER = 5
  53. SESSION_SECURITY_EXPIRE_AFTER = 12
  54. TEMPLATES = [
  55. {
  56. "BACKEND": "django.template.backends.django.DjangoTemplates",
  57. "DIRS": [os.path.join(BASE_DIR, "templates")],
  58. "APP_DIRS": True,
  59. "OPTIONS": {
  60. "context_processors": [
  61. "django.template.context_processors.debug",
  62. "django.template.context_processors.request",
  63. "django.contrib.auth.context_processors.auth",
  64. "django.template.context_processors.i18n",
  65. "django.template.context_processors.media",
  66. "django.template.context_processors.static",
  67. "django.template.context_processors.tz",
  68. "django.contrib.messages.context_processors.messages",
  69. ],
  70. },
  71. }
  72. ]
  73. WSGI_APPLICATION = 'core.wsgi.application'
  74. # Database
  75. # https://docs.djangoproject.com/en/4.0/ref/settings/#databases
  76. DATABASES = {
  77. 'default': {
  78. 'ENGINE': 'django.db.backends.postgresql',
  79. 'NAME': "sowb_test",
  80. 'USER': "test",
  81. 'PASSWORD': "Test!@!12345&!&",
  82. 'HOST': "127.0.0.1",
  83. 'PORT': '5432',
  84. }
  85. }
  86. # Password validation
  87. # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
  88. AUTH_PASSWORD_VALIDATORS = [
  89. {
  90. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  91. },
  92. {
  93. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  94. },
  95. {
  96. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  97. },
  98. {
  99. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  100. },
  101. ]
  102. # Internationalization
  103. # https://docs.djangoproject.com/en/4.0/topics/i18n/
  104. LANGUAGE_CODE = 'ru'
  105. USE_TZ = True
  106. TIME_ZONE = 'Europe/Moscow'
  107. SITE_ID = 1
  108. # If you set this to False, Django will make some optimizations so as not
  109. # to load the internationalization machinery.
  110. USE_I18N = True
  111. # Static files (CSS, JavaScript, Images)
  112. # https://docs.djangoproject.com/en/4.0/howto/static-files/
  113. STATIC_URL = "/static/"
  114. STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
  115. # Uploaded media
  116. MEDIA_URL = "/media/"
  117. MEDIA_ROOT = os.path.join(BASE_DIR, "media")
  118. # Without this, uploaded files > 4MB end up with perm 0600, unreadable by web server process
  119. FILE_UPLOAD_PERMISSIONS = 0o644
  120. # Override CSS class for the ERROR tag level to match Bootstrap class name
  121. MESSAGE_TAGS = {message_constants.ERROR: "danger"}
  122. # Default primary key field type
  123. # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
  124. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  125. AUTH_USER_MODEL = 'SharixAdmin.SharixUser'
  126. class ConfigJazzmin:
  127. JAZZMIN_SETTINGS = {
  128. # title of the window (Will default to current_admin_site.site_title if absent or None)
  129. "site_title": "ShariX Admin",
  130. # Title on the login screen (19 chars max) (defaults to current_admin_site.site_header if absent or None)
  131. "site_header": "ShariX Platform",
  132. # Title on the brand (19 chars max) (defaults to current_admin_site.site_header if absent or None)
  133. "site_brand": "ShariX Platform",
  134. # Logo to use for your site, must be present in static files, used for brand on top left
  135. "site_logo": "SharixAdmin/img/logo.svg",
  136. # Logo to use for your site, must be present in static files, used for login form logo (defaults to site_logo)
  137. "login_logo": None,
  138. # Logo to use for login form in dark themes (defaults to login_logo)
  139. "login_logo_dark": None,
  140. # CSS classes that are applied to the logo above
  141. "site_logo_classes": "img-circle",
  142. # Relative path to a favicon for your site, will default to site_logo if absent (ideally 32x32 px)
  143. "site_icon": None,
  144. # Welcome text on the login screen
  145. "welcome_sign": "Welcome to the ShariX Admin",
  146. # Copyright on the footer
  147. "copyright": "Acme Library Ltd",
  148. # List of model admins to search from the search bar, search bar omitted if excluded
  149. # If you want to use a single search field you dont need to use a list, you can use a simple string
  150. "search_model": ["SharixAdmin.SharixUser"],
  151. # Field name on user model that contains avatar ImageField/URLField/Charfield or a callable that receives the user
  152. "user_avatar": "",
  153. ############
  154. # Top Menu #
  155. ############
  156. # Links to put along the top menu
  157. "topmenu_links": [
  158. # Url that gets reversed (Permissions can be added)
  159. {"name": "Главная", "url": "admin:index", "permissions": ["auth.view_user"]},
  160. # external url that opens in a new window (Permissions can be added)
  161. #{"name": "Support", "url": "https://github.com/farridav/django-jazzmin/issues", "new_window": True},
  162. # model admin to link to (Permissions checked against model)
  163. {"model": "SharixAdmin.SharixUser"},
  164. # App with dropdown menu to all its models pages (Permissions checked against models)
  165. {"app": "tickets"},
  166. ],
  167. #############
  168. # User Menu #
  169. #############
  170. # Additional links to include in the user menu on the top right ("app" url type is not allowed)
  171. # "usermenu_links": [
  172. # {"name": "Support", "url": "https://github.com/farridav/django-jazzmin/issues", "new_window": True},
  173. # {"model": "SharixAdmin.SharixUser"}
  174. # ],
  175. # #############
  176. # # Side Menu #
  177. # #############
  178. # # Whether to display the side menu
  179. # "show_sidebar": True,
  180. # # Whether to aut expand the menu
  181. # "navigation_expanded": True,
  182. # # Hide these apps when generating side menu e.g (auth)
  183. # "hide_apps": [],
  184. # # Hide these models when generating side menu (e.g auth.user)
  185. # "hide_models": [],
  186. # # List of apps (and/or models) to base side menu ordering off of (does not need to contain all apps/models)
  187. # #"order_with_respect_to": ["auth", "books", "books.author", "books.book"],
  188. # # Custom links to append to app groups, keyed on app name
  189. # "custom_links": {
  190. # "tickets": [{
  191. # "name": "Make Messages",
  192. # "url": "make_messages",
  193. # "icon": "fas fa-comments",
  194. # "permissions": ["tickets.view_book"]
  195. # }]
  196. # },
  197. # # Custom icons for side menu apps/models See https://fontawesome.com/icons?d=gallery&m=free&v=5.0.0,5.0.1,5.0.10,5.0.11,5.0.12,5.0.13,5.0.2,5.0.3,5.0.4,5.0.5,5.0.6,5.0.7,5.0.8,5.0.9,5.1.0,5.1.1,5.2.0,5.3.0,5.3.1,5.4.0,5.4.1,5.4.2,5.13.0,5.12.0,5.11.2,5.11.1,5.10.0,5.9.0,5.8.2,5.8.1,5.7.2,5.7.1,5.7.0,5.6.3,5.5.0,5.4.2
  198. # # for the full list of 5.13.0 free icon classes
  199. "icons": {
  200. "auth": "fas fa-users-cog",
  201. "auth.user": "fas fa-user",
  202. "auth.Group": "fas fa-users",
  203. "SharixAdmin": "fas fa-users-cog",
  204. "SharixAdmin.SharixUser": "fas fa-user",
  205. "tickets.Task": "fas fa-check",
  206. "tickets.TaskList": "fas fa-list",
  207. "tickets.Comment": "fas fa-comment",
  208. "tickets.Attachment": "fas fa-file",
  209. },
  210. # # Icons that are used when one is not manually specified
  211. # # "default_icon_parents": "fas fa-chevron-circle-right",
  212. # # "default_icon_children": "fas fa-circle",
  213. # #################
  214. # # Related Modal #
  215. # #################
  216. # # Use modals instead of popups
  217. # "related_modal_active": False,
  218. # #############
  219. # # UI Tweaks #
  220. # #############
  221. # # Relative paths to custom CSS/JS scripts (must be present in static files)
  222. "custom_css": None,
  223. "custom_js": None,
  224. # Whether to link font from fonts.googleapis.com (use custom_css to supply font otherwise)
  225. "use_google_fonts_cdn": True,
  226. # # Whether to show the UI customizer on the sidebar
  227. "show_ui_builder": True,
  228. ###############
  229. # Change view #
  230. ###############
  231. # Render out the change view as a single form, or in tabs, current options are
  232. # - single
  233. # - horizontal_tabs (default)
  234. # - vertical_tabs
  235. # - collapsible
  236. # - carousel
  237. #"changeform_format": "horizontal_tabs",
  238. # override change forms on a per modeladmin basis
  239. #"changeform_format_overrides": {"SharixAdmin.SharixUser": "collapsible", "auth.group": "vertical_tabs"},
  240. # Add a language dropdown into the admin
  241. #"language_chooser": True,
  242. }
  243. JAZZMIN_UI_TWEAKS = {
  244. "navbar_small_text": True,
  245. "footer_small_text": True,
  246. "body_small_text": False,
  247. "brand_small_text": True,
  248. "brand_colour": "navbar-light",
  249. "accent": "accent-navy",
  250. "navbar": "navbar-navy navbar-dark",
  251. "no_navbar_border": False,
  252. "navbar_fixed": False,
  253. "layout_boxed": False,
  254. "footer_fixed": False,
  255. "sidebar_fixed": True,
  256. "sidebar": "sidebar-light-navy",
  257. "sidebar_nav_small_text": False,
  258. "sidebar_disable_expand": False,
  259. "sidebar_nav_child_indent": False,
  260. "sidebar_nav_compact_style": True,
  261. "sidebar_nav_legacy_style": False,
  262. "sidebar_nav_flat_style": False,
  263. "theme": "default",
  264. "dark_mode_theme": None,
  265. "button_classes": {
  266. "primary": "btn-outline-primary",
  267. "secondary": "btn-outline-secondary",
  268. "info": "btn-outline-info",
  269. "warning": "btn-outline-warning",
  270. "danger": "btn-outline-danger",
  271. "success": "btn-outline-success"
  272. },
  273. "actions_sticky_top": False
  274. }
  275. class ConfigAPI:
  276. REST_FRAMEWORK = {
  277. # Use Django's standard `django.contrib.auth` permissions,
  278. # or allow read-only access for unauthenticated users.
  279. 'DEFAULT_RENDERER_CLASSES':[
  280. 'rest_framework.renderers.JSONRenderer',
  281. 'rest_framework.renderers.BrowsableAPIRenderer',
  282. ],
  283. 'DEFAULT_PERMISSION_CLASSES': [
  284. #'rest_framework.permissions.AllowAny',
  285. #'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
  286. ],
  287. 'DEFAULT_AUTHENTICATION_CLASSES': (
  288. 'rest_framework.authentication.TokenAuthentication',
  289. 'rest_framework.authentication.BasicAuthentication',
  290. 'rest_framework.authentication.SessionAuthentication',
  291. ),
  292. }
  293. SPAGHETTI_SAUCE = {
  294. 'apps': ['auth', 'SharixAdmin',
  295. 'tickets', 'admin',
  296. 'flatpages', 'sessions', 'sites', 'dbsynce'],
  297. 'show_fields': False,
  298. 'show_proxy':True,
  299. }
  300. GRAPH_MODELS = {
  301. 'all_applications': True,
  302. 'group_models': True,
  303. }
  304. DJOSER = {
  305. 'SERIALIZERS': {
  306. 'token': 'SharixAdmin.api.serializers.CustomTokenSerializer',
  307. }
  308. }
  309. class ConfigGunicorn:
  310. bind = "10.0.20.10:8000"
  311. workers = 2
  312. worker_class = "sync"
  313. threads = 4
  314. timeout = 30
  315. max_requests = 1000
  316. capture_output = True