Project And Teamorganisation Tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.py 6.9KB

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