""" Django settings for digipus project. Generated by 'django-admin startproject' using Django 3.0.3. For more information on this file, see https://docs.djangoproject.com/en/3.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os import dj_database_url from decouple import config from django.contrib.messages import constants as messages # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", cast=bool) ALLOWED_HOSTS = ["*"] # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", 'django.contrib.humanize', "authentication.apps.AuthenticationConfig", "app.apps.AppConfig", "register.apps.RegisterConfig", "administration.apps.AdministrationConfig", 'crispy_forms', "news.apps.NewsConfig", "traffic_statistics", "forum", "rest_framework", 'userguide' ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", ] SESSION_SAVE_EVERY_REQUEST = True ROOT_URLCONF = "digipus.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [os.path.join(BASE_DIR, "templates")], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "authentication.views.kontributor_notif_context" ], }, }, ] WSGI_APPLICATION = "digipus.wsgi.application" # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases is_local = config("IS_LOCAL", cast=bool, default=False) is_heroku = config("IS_HEROKU", cast=bool, default=False) is_gitlab = config("IS_GITLAB", cast=bool, default=False) if is_local: DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", "NAME": config("DB_NAME"), "USER": config("DB_USER"), "PASSWORD": config("DB_PASSWORD"), "HOST": config("DB_HOST"), "PORT": config("DB_PORT", 5432), } } elif is_heroku: DATABASES = {} database_url = os.getenv("DATABASE_URL") DATABASES["default"] = dj_database_url.parse( database_url, conn_max_age=600) elif is_gitlab: DATABASES = {} database_url = config("DATABASE_URL", cast=str, default=False) DATABASES["default"] = dj_database_url.parse( database_url, conn_max_age=600) else: DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": os.path.join(BASE_DIR, "db.sqlite3"), }} STATICFILES_DIRS = (os.path.join(BASE_DIR, "staticfiles"),) # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators AUTH_USER_MODEL = "authentication.User" AUTH_PASSWORD_VALIDATORS = [ {"NAME": "app.utils.PasswordValidator.PasswordPolicyValidator", }, ] # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "Asia/Jakarta" USE_I18N = True USE_L10N = True USE_TZ = True MESSAGE_TAGS = { messages.DEBUG: 'alert-info', messages.INFO: 'alert-info', messages.SUCCESS: 'alert-success', messages.WARNING: 'alert-warning', messages.ERROR: 'alert-danger', } GOOGLE_RECAPTCHA_SECRET_KEY = config('GOOGLE_RECHAPTCHA', default= "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe") GOOGLE_RECAPTCHA_SITE_KEY = config('CLIENT_RECHAPTCHA', default= "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI") # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_ROOT = os.path.join(BASE_DIR, "static") STATIC_URL = "/static/" STATIC_DIRS = [ os.path.join(BASE_DIR, "static"), ] STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_URL = "/media/" LOGOUT_REDIRECT_URL = "/" CRISPY_TEMPLATE_PACK = 'bootstrap4' REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.authentication.JWTAuthentication', ], } # Mail # https://docs.djangoproject.com/en/3.1/topics/email/ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = config('EMAIL_HOST', default='smtp.gmail.com') # use Google Mail SMTP as default EMAIL_PORT = config('EMAIL_PORT', default=587) # use Google Mail SMTP as default EMAIL_HOST_USER = config('EMAIL_HOST_USER', default="pmplclass2020@gmail.com") EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default="pmpldigipusemail") EMAIL_USE_TLS = True EMAIL_USE_SSL = False