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

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