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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. ]
  34. MIDDLEWARE = [
  35. 'django.middleware.security.SecurityMiddleware',
  36. 'django.contrib.sessions.middleware.SessionMiddleware',
  37. 'django.middleware.common.CommonMiddleware',
  38. 'django.middleware.csrf.CsrfViewMiddleware',
  39. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  40. 'django.contrib.messages.middleware.MessageMiddleware',
  41. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  42. ]
  43. ROOT_URLCONF = 'mysite.urls'
  44. TEMPLATES = [
  45. {
  46. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  47. 'DIRS': [],
  48. 'APP_DIRS': True,
  49. 'OPTIONS': {
  50. 'context_processors': [
  51. 'django.template.context_processors.debug',
  52. 'django.template.context_processors.request',
  53. 'django.contrib.auth.context_processors.auth',
  54. 'django.contrib.messages.context_processors.messages',
  55. ],
  56. },
  57. },
  58. ]
  59. WSGI_APPLICATION = 'mysite.wsgi.application'
  60. # Database
  61. # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  62. if DEVELOPMENT:
  63. DATABASES = {
  64. 'default': {
  65. 'ENGINE': 'django.db.backends.sqlite3',
  66. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  67. }
  68. }
  69. print(" --- Development sqlite database --- ")
  70. else:
  71. DATABASES = {
  72. 'default': {
  73. 'ENGINE': 'django.db.backends.mysql',
  74. 'NAME': 'django-app',
  75. 'USER': 'django-app',
  76. 'PASSWORD': '*******',
  77. 'HOST': 'mysql',
  78. 'PORT': '3306',
  79. 'OPTIONS': {
  80. 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
  81. },
  82. }
  83. }
  84. # Password validation
  85. # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  86. AUTH_PASSWORD_VALIDATORS = [
  87. {
  88. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  89. },
  90. {
  91. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  92. },
  93. {
  94. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  95. },
  96. {
  97. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  98. },
  99. ]
  100. # Internationalization
  101. # https://docs.djangoproject.com/en/2.0/topics/i18n/
  102. LANGUAGE_CODE = 'en-us'
  103. TIME_ZONE = 'Europe/Berlin'
  104. USE_I18N = True
  105. USE_L10N = True
  106. USE_TZ = True
  107. # Static files (CSS, JavaScript, Images)
  108. # https://docs.djangoproject.com/en/2.0/howto/static-files/
  109. STATIC_URL = '/static/'
  110. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  111. # Konfiguration des Auth-Systems
  112. LDAP_DOMAIN = 'ADS1'
  113. LDAP_SERVER = 'gso1.ads1.fh-nuernberg.de'
  114. if DEVELOPMENT:
  115. LOGIN_REDIRECT_URL = '/'
  116. LOGOUT_REDIRECT_URL = '/'
  117. LOGIN_URL = "/accounts/login/"
  118. else:
  119. LOGIN_REDIRECT_URL = '/app/'
  120. LOGOUT_REDIRECT_URL = '/app/'
  121. LOGIN_URL = "/app/accounts/login/"
  122. if DEVELOPMENT:
  123. AUTHENTICATION_BACKENDS = [
  124. 'django.contrib.auth.backends.ModelBackend',
  125. ]
  126. print(" --- Development stage --- ")
  127. else:
  128. AUTHENTICATION_BACKENDS = [
  129. 'django.contrib.auth.backends.ModelBackend',
  130. 'mysite.ldap_backend.LdapBackend',
  131. ]
  132. print(" --- Live stage --- ")