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.8KB

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