furry/webshop/settings.py

205 lines
5.7 KiB
Python

"""
Django settings for webshop project.
Generated by 'django-admin startproject' using Django 5.2.1.
For more information on this file, see
https://docs.djangoproject.com/en/5.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.2/ref/settings/
"""
from pathlib import Path
import os
from dotenv import load_dotenv
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Lade .env Datei
load_dotenv(BASE_DIR / '.env')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-qddfdhpsm$=%o8p74xo8q9wbsa5^818(dzl4f&yrdcyn=050dt')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv('DEBUG', 'True') == 'True'
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'shop.apps.ShopConfig',
'products.apps.ProductsConfig',
'paypal_integration',
'paypal.standard.ipn',
'payments',
]
# Entferne den zusätzlichen staticfiles-Block
if DEBUG:
INSTALLED_APPS += []
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'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',
]
ROOT_URLCONF = 'webshop.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'webshop.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.2/topics/i18n/
LANGUAGE_CODE = 'de'
LANGUAGES = [
('de', 'Deutsch'),
('en', 'English'),
]
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_DIRS = [
BASE_DIR / 'static',
]
# Media files (Uploads)
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
# Stellen Sie sicher, dass der media-Ordner existiert
if not os.path.exists(MEDIA_ROOT):
os.makedirs(MEDIA_ROOT)
# Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Stripe Einstellungen
STRIPE_PUBLISHABLE_KEY = os.getenv('STRIPE_PUBLISHABLE_KEY', '')
STRIPE_SECRET_KEY = os.getenv('STRIPE_SECRET_KEY', '')
STRIPE_WEBHOOK_SECRET = os.getenv('STRIPE_WEBHOOK_SECRET', '')
# E-Mail-Einstellungen (temporär Console-Backend)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = 'Fursuit Shop <noreply@fursuitshop.com>'
# Admin-E-Mail-Empfänger
ADMINS = [
('Shop Admin', 'admin@fursuitshop.com'),
]
# Lagerbestand-Einstellungen
LOW_STOCK_THRESHOLD = 5 # Schwellenwert für niedrigen Lagerbestand
# Authentication Settings
LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'products:product_list'
LOGOUT_REDIRECT_URL = 'shop:home'
SITE_URL = os.getenv('SITE_URL', 'http://127.0.0.1:8000')
# PayPal Einstellungen
PAYPAL_TEST = True
PAYPAL_RECEIVER_EMAIL = 'sb-43wjt28371773@business.example.com'
PAYPAL_CURRENCY_CODE = 'EUR'
# PayPal URLs
PAYPAL_BN = 'Fursuit_Shop'
PAYPAL_RETURN_URL = f'{SITE_URL}/products/payment/success/'
PAYPAL_CANCEL_URL = f'{SITE_URL}/products/payment/failed/'
PAYPAL_NOTIFY_URL = f'{SITE_URL}/paypal/'
# Sites Framework
SITE_ID = 1
# Payment settings
PAYMENT_HOST = SITE_URL
PAYMENT_USES_SSL = False # Set to True in production
PAYMENT_MODEL = 'products.Payment'
PAYMENT_VARIANTS = {
'default': ('payments.dummy.DummyProvider', {}),
'stripe': ('payments.stripe.StripeProvider', {
'secret_key': STRIPE_SECRET_KEY,
'public_key': STRIPE_PUBLISHABLE_KEY
})
}