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

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