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

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