Development of an internal social media platform with personalised dashboards for students
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 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. """
  2. Django settings for mysite project.
  3. Generated by 'django-admin startproject' using Django 2.0.6.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.0/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.0/ref/settings/
  8. """
  9. import os
  10. import re
  11. import socket
  12. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  13. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  14. # Quick-start development settings - unsuitable for production
  15. # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  16. # SECURITY WARNING: keep the secret key used in production secret!
  17. SECRET_KEY = 'rh2cynsps7=3fb-bmb!+6g(!a(j5i3dq54ps08y2^py8z*49ct'
  18. # SECURITY WARNING: don't run with debug turned on in production!
  19. DEBUG = True
  20. ALLOWED_HOSTS = []
  21. # Development or Production
  22. r = re.search(r'^172.17', socket.gethostbyname(socket.gethostname()))
  23. DEVELOPMENT = (r == None)
  24. # Application definition
  25. INSTALLED_APPS = [
  26. 'django.contrib.admin',
  27. 'django.contrib.auth',
  28. 'django.contrib.contenttypes',
  29. 'django.contrib.sessions',
  30. 'django.contrib.messages',
  31. 'django.contrib.staticfiles',
  32. 'application',
  33. 'taggit',
  34. 'taggit_templatetags2',
  35. ]
  36. MIDDLEWARE = [
  37. 'django.middleware.security.SecurityMiddleware',
  38. 'django.contrib.sessions.middleware.SessionMiddleware',
  39. 'django.middleware.common.CommonMiddleware',
  40. 'django.middleware.csrf.CsrfViewMiddleware',
  41. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  42. 'django.contrib.messages.middleware.MessageMiddleware',
  43. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  44. ]
  45. ROOT_URLCONF = 'mysite.urls'
  46. TEMPLATES = [
  47. {
  48. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  49. 'DIRS': [],
  50. 'APP_DIRS': True,
  51. 'OPTIONS': {
  52. 'context_processors': [
  53. 'django.template.context_processors.debug',
  54. 'django.template.context_processors.request',
  55. 'django.contrib.auth.context_processors.auth',
  56. 'django.contrib.messages.context_processors.messages',
  57. ],
  58. },
  59. },
  60. ]
  61. WSGI_APPLICATION = 'mysite.wsgi.application'
  62. # Database
  63. # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  64. if DEVELOPMENT:
  65. DATABASES = {
  66. 'default': {
  67. 'ENGINE': 'django.db.backends.sqlite3',
  68. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  69. }
  70. }
  71. print(" --- Development sqlite database --- ")
  72. else:
  73. DATABASES = {
  74. 'default': {
  75. 'ENGINE': 'django.db.backends.mysql',
  76. 'NAME': 'django-app',
  77. 'USER': 'django-app',
  78. 'PASSWORD': '*******',
  79. 'HOST': 'mysql',
  80. 'PORT': '3306',
  81. 'OPTIONS': {
  82. 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
  83. },
  84. }
  85. }
  86. # Password validation
  87. # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  88. AUTH_PASSWORD_VALIDATORS = [
  89. {
  90. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  91. },
  92. {
  93. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  94. },
  95. {
  96. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  97. },
  98. {
  99. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  100. },
  101. ]
  102. # Internationalization
  103. # https://docs.djangoproject.com/en/2.0/topics/i18n/
  104. LANGUAGE_CODE = 'en-us'
  105. TIME_ZONE = 'Europe/Berlin'
  106. USE_I18N = True
  107. USE_L10N = True
  108. USE_TZ = True
  109. # Static files (CSS, JavaScript, Images)
  110. # https://docs.djangoproject.com/en/2.0/howto/static-files/
  111. STATIC_URL = '/static/'
  112. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  113. # Konfiguration des Auth-Systems
  114. LDAP_DOMAIN = 'ADS1'
  115. LDAP_SERVER = 'gso1.ads1.fh-nuernberg.de'
  116. if DEVELOPMENT:
  117. LOGIN_REDIRECT_URL = '/'
  118. LOGOUT_REDIRECT_URL = '/'
  119. LOGIN_URL = "/accounts/login/"
  120. else:
  121. LOGIN_REDIRECT_URL = '/app/'
  122. LOGOUT_REDIRECT_URL = '/app/'
  123. LOGIN_URL = "/app/accounts/login/"
  124. if DEVELOPMENT:
  125. AUTHENTICATION_BACKENDS = [
  126. 'django.contrib.auth.backends.ModelBackend',
  127. ]
  128. print(" --- Development stage --- ")
  129. else:
  130. AUTHENTICATION_BACKENDS = [
  131. 'django.contrib.auth.backends.ModelBackend',
  132. 'mysite.ldap_backend.LdapBackend',
  133. ]
  134. print(" --- Live stage --- ")