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