Project And Teamorganisation Tool
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

settings.py 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. """
  2. Django settings for patt project.
  3. Generated by 'django-admin startproject' using Django 5.1.1.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/5.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/3.0/ref/settings/
  8. """
  9. from pathlib import Path
  10. import config
  11. from logging.handlers import SocketHandler as _SocketHandler
  12. import os
  13. import random
  14. import stat
  15. import sys
  16. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  17. BASE_DIR = Path(__file__).resolve().parent.parent
  18. # Quick-start development settings - unsuitable for production
  19. # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
  20. # Application definition
  21. INSTALLED_APPS = [
  22. 'patt.apps.PattConfig',
  23. 'themes.apps.ThemesConfig',
  24. 'mycreole.apps.MycreoleConfig',
  25. 'users.apps.UsersConfig',
  26. #
  27. 'django.contrib.admin',
  28. 'django.contrib.auth',
  29. 'django.contrib.contenttypes',
  30. 'django.contrib.sessions',
  31. 'django.contrib.messages',
  32. 'django.contrib.staticfiles',
  33. 'simple_history',
  34. ]
  35. MIDDLEWARE = [
  36. 'django.middleware.security.SecurityMiddleware',
  37. 'django.contrib.sessions.middleware.SessionMiddleware',
  38. 'django.middleware.locale.LocaleMiddleware',
  39. 'django.middleware.common.CommonMiddleware',
  40. 'django.middleware.csrf.CsrfViewMiddleware',
  41. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  42. 'django.contrib.messages.middleware.MessageMiddleware',
  43. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  44. 'simple_history.middleware.HistoryRequestMiddleware',
  45. 'users.middleware.SettingsMiddleware',
  46. ]
  47. ROOT_URLCONF = 'main.urls'
  48. TEMPLATES = [
  49. {
  50. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  51. 'DIRS': [],
  52. 'APP_DIRS': True,
  53. 'OPTIONS': {
  54. 'context_processors': [
  55. 'django.template.context_processors.debug',
  56. 'django.template.context_processors.request',
  57. 'django.contrib.auth.context_processors.auth',
  58. 'django.contrib.messages.context_processors.messages',
  59. ],
  60. },
  61. },
  62. ]
  63. WSGI_APPLICATION = 'main.wsgi.application'
  64. # Database
  65. # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
  66. DATABASES = {
  67. 'default': {
  68. 'ENGINE': 'django.db.backends.sqlite3',
  69. 'NAME': BASE_DIR / 'db.sqlite3',
  70. }
  71. }
  72. # Password validation
  73. # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
  74. AUTH_PASSWORD_VALIDATORS = [
  75. {
  76. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  77. },
  78. {
  79. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  80. },
  81. {
  82. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  83. },
  84. {
  85. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  86. },
  87. ]
  88. # Internationalization
  89. # https://docs.djangoproject.com/en/5.1/topics/i18n/
  90. LANGUAGE_CODE = 'en-us'
  91. LANGUAGES = [
  92. ('en', 'English'),
  93. ('de', 'Deutsch'),
  94. ]
  95. TIME_ZONE = 'UTC'
  96. USE_I18N = True
  97. LOCALE_PATHS = [
  98. os.path.join(BASE_DIR, 'themes', 'locale'),
  99. os.path.join(BASE_DIR, 'users', 'locale'),
  100. os.path.join(BASE_DIR, 'patt', 'locale'),
  101. ]
  102. USE_L10N = True
  103. USE_TZ = True
  104. # Static files (CSS, JavaScript, Images)
  105. # https://docs.djangoproject.com/en/5.1/howto/static-files/
  106. STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
  107. STATIC_URL = 'static/'
  108. MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
  109. MEDIA_URL = '/media/'
  110. USERS_PROFILE_ADDITIONS = {"PaTT Profile": 'patt.forms.PattUserProfileForm'}
  111. MYCREOLE_ROOT = os.path.join(BASE_DIR, 'data', 'mycreole')
  112. MYCREOLE_ATTACHMENT_ACCESS = {
  113. 'read': 'patt.access.read_attachment',
  114. 'modify': 'patt.access.modify_attachment',
  115. }
  116. MYCREOLE_BAR = {
  117. 'navibar': 'patt.context.navigationbar',
  118. 'menubar': 'patt.context.menubar',
  119. }
  120. MYCREOLE_EXT_FILTERS = [
  121. 'patt.creole.task_link_filter',
  122. 'patt.creole.tasklist_link_filter',
  123. ]
  124. WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
  125. LOGIN_URL = 'users-login'
  126. # Default primary key field type
  127. # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
  128. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  129. # Check permission of config.py
  130. #
  131. if sys.platform == 'linux' or sys.platform == 'linux2':
  132. st = os.stat(os.path.join(BASE_DIR, 'config.py'))
  133. if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
  134. raise PermissionError("conig.py is readable by group or others.")
  135. # Default values, if not defined in config.py
  136. #
  137. USER_CONFIG_DEFAULTS = {
  138. 'DEBUG': False,
  139. 'SECRET_KEY': None,
  140. 'DEFAULT_THEME': 'clear-green',
  141. 'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ],
  142. 'CSRF_TRUSTED_ORIGINS': [],
  143. }
  144. # Set configuration parameters
  145. #
  146. thismodule = sys.modules[__name__]
  147. for property_name in USER_CONFIG_DEFAULTS:
  148. try:
  149. value = getattr(config, property_name)
  150. except AttributeError:
  151. value = USER_CONFIG_DEFAULTS[property_name]
  152. setattr(thismodule, property_name, value)
  153. # SECURITY WARNING: keep the secret key used in production secret!
  154. #
  155. if SECRET_KEY is None:
  156. chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
  157. s_key = ''.join([random.choice(chars) for n in range(50)])
  158. secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
  159. raise KeyError(secret_key_warning)
  160. # Logging Configuration
  161. #
  162. ROOT_LOGGER_NAME = os.path.basename(os.path.dirname(__file__))
  163. default_handler = ['socket', 'console'] if DEBUG else ['console']
  164. class DjangoSocketHandler(_SocketHandler):
  165. def emit(self, record):
  166. if hasattr(record, 'request'):
  167. record.request = None
  168. return super().emit(record)
  169. LOGGING = {
  170. 'version': 1,
  171. 'disable_existing_loggers': False,
  172. 'formatters': {
  173. 'short': {
  174. 'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
  175. 'datefmt': '[%d/%b/%Y %H:%M:%S]',
  176. },
  177. 'long': {
  178. 'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. File "%(pathname)s", line %(lineno)d, in %(funcName)s
  180. %(asctime)s: %(name)s - %(message)s
  181. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
  182. },
  183. },
  184. 'handlers': {
  185. 'console': {
  186. 'level': 'DEBUG',
  187. 'class': 'logging.StreamHandler',
  188. 'formatter': 'short',
  189. },
  190. 'socket': {
  191. 'level': 'DEBUG',
  192. 'class': f'{ROOT_LOGGER_NAME}.settings.DjangoSocketHandler',
  193. 'host': '127.0.0.1',
  194. 'port': 19996,
  195. },
  196. },
  197. 'loggers': {
  198. 'django': {
  199. 'handlers': default_handler,
  200. 'level': 'INFO',
  201. 'propagate': False,
  202. },
  203. ROOT_LOGGER_NAME: {
  204. 'handlers': default_handler,
  205. 'level': 'DEBUG' if DEBUG else 'INFO',
  206. 'propagate': False,
  207. },
  208. },
  209. }