130 lines
4.2 KiB
Python
130 lines
4.2 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Docker Initialisierungsskript für Kasico Fursuit Shop
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import django
|
|
from django.core.management import execute_from_command_line
|
|
|
|
def init_docker():
|
|
"""Initialisiere Django für Docker"""
|
|
|
|
# Setze Django Settings
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webshop.settings')
|
|
|
|
# Setup Django
|
|
django.setup()
|
|
|
|
print("🐳 Initialisiere Kasico Fursuit Shop für Docker...")
|
|
|
|
try:
|
|
# Führe Migrationen aus
|
|
print("📦 Führe Datenbank-Migrationen aus...")
|
|
execute_from_command_line(['manage.py', 'migrate'])
|
|
|
|
# Erstelle Superuser falls nicht vorhanden
|
|
from django.contrib.auth.models import User
|
|
if not User.objects.filter(username='admin').exists():
|
|
print("👤 Erstelle Admin-User...")
|
|
User.objects.create_superuser('admin', 'admin@kasico.de', 'admin123')
|
|
print("✅ Admin-User erstellt: admin / admin123")
|
|
|
|
# Erstelle Test-Daten
|
|
print("🎨 Erstelle Test-Daten...")
|
|
create_test_data()
|
|
|
|
# Erstelle Elasticsearch Index
|
|
print("🔍 Erstelle Elasticsearch Index...")
|
|
execute_from_command_line(['manage.py', 'rebuild_index', '--noinput'])
|
|
|
|
print("✅ Docker Initialisierung abgeschlossen!")
|
|
print("🌐 Server läuft auf: http://localhost:8000")
|
|
print("👤 Admin Panel: http://localhost:8000/admin")
|
|
print("📧 Login: admin / admin123")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Fehler bei der Initialisierung: {e}")
|
|
sys.exit(1)
|
|
|
|
def create_test_data():
|
|
"""Erstelle Test-Daten für den Shop"""
|
|
|
|
from products.models import Product, Category
|
|
from django.core.files.base import ContentFile
|
|
|
|
# Erstelle Kategorien
|
|
categories = [
|
|
{'name': 'Fursuits', 'description': 'Vollständige Fursuits'},
|
|
{'name': 'Köpfe', 'description': 'Fursuit Köpfe'},
|
|
{'name': 'Pfoten', 'description': 'Fursuit Pfoten'},
|
|
{'name': 'Schwänze', 'description': 'Fursuit Schwänze'},
|
|
]
|
|
|
|
for cat_data in categories:
|
|
Category.objects.get_or_create(
|
|
name=cat_data['name'],
|
|
defaults={'description': cat_data['description']}
|
|
)
|
|
|
|
# Erstelle Test-Produkte
|
|
products_data = [
|
|
{
|
|
'name': 'Wolf Fursuit - Luna',
|
|
'description': 'Vollständiger Wolf Fursuit in silber-grau',
|
|
'price': 2500.00,
|
|
'category': 'Fursuits',
|
|
'fursuit_type': 'fullsuit',
|
|
'stock': 1,
|
|
'featured': True
|
|
},
|
|
{
|
|
'name': 'Fuchs Kopf - Blaze',
|
|
'description': 'Fuchs Kopf in orange-rot mit LED Augen',
|
|
'price': 800.00,
|
|
'category': 'Köpfe',
|
|
'fursuit_type': 'head',
|
|
'stock': 3,
|
|
'featured': True
|
|
},
|
|
{
|
|
'name': 'Hund Pfoten - Buddy',
|
|
'description': 'Hund Pfoten in braun mit Krallen',
|
|
'price': 300.00,
|
|
'category': 'Pfoten',
|
|
'fursuit_type': 'paws',
|
|
'stock': 5,
|
|
'featured': False
|
|
},
|
|
{
|
|
'name': 'Katze Schwanz - Whiskers',
|
|
'description': 'Katze Schwanz in schwarz mit Bewegungsmechanismus',
|
|
'price': 200.00,
|
|
'category': 'Schwänze',
|
|
'fursuit_type': 'tail',
|
|
'stock': 8,
|
|
'featured': False
|
|
},
|
|
]
|
|
|
|
for prod_data in products_data:
|
|
category = Category.objects.get(name=prod_data['category'])
|
|
product, created = Product.objects.get_or_create(
|
|
name=prod_data['name'],
|
|
defaults={
|
|
'description': prod_data['description'],
|
|
'price': prod_data['price'],
|
|
'category': category,
|
|
'fursuit_type': prod_data['fursuit_type'],
|
|
'stock': prod_data['stock'],
|
|
'featured': prod_data['featured'],
|
|
'is_active': True
|
|
}
|
|
)
|
|
|
|
if created:
|
|
print(f"✅ Produkt erstellt: {product.name}")
|
|
|
|
if __name__ == '__main__':
|
|
init_docker() |