Fix: /breeder/my-editor Endpoint (Crash 'Cannot destructure profile') + Läufigkeit in Züchter-Bereich
breeder-editor.js (aus 459cd42) rief /api/breeder/my-editor auf — Endpoint
existierte nie (gleicher Worktree-Verlust wie /partner/my-profile). Jetzt
gebaut: profile + litters + storage_mb/limit; ohne Profil klare 404 statt
Destrukturierungs-Crash. 3 Tests.
Läufigkeit (Rene): eigener HUND-Chip entfällt, stattdessen vierte Karte im
Züchter-Bereich (Zyklen, Progesterontests, Deckdaten). Suite: 58 passed.
This commit is contained in:
parent
ed7c469c6a
commit
487dacc7c7
9 changed files with 100 additions and 20 deletions
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
1266
|
1267
|
||||||
|
|
@ -491,6 +491,43 @@ class BreederProfileUpdate(BaseModel):
|
||||||
website: Optional[str] = Field(None, max_length=500)
|
website: Optional[str] = Field(None, max_length=500)
|
||||||
beschreibung: Optional[str] = Field(None, max_length=10000)
|
beschreibung: Optional[str] = Field(None, max_length=10000)
|
||||||
|
|
||||||
|
@router.get("/breeder/my-editor")
|
||||||
|
async def breeder_my_editor(user=Depends(require_breeder)):
|
||||||
|
"""Daten für den Profil-Editor: Profil + eigene Würfe + Speicherverbrauch.
|
||||||
|
(Frontend breeder-editor.js stammt aus 459cd42 — dieser Lese-Endpoint
|
||||||
|
ging damals im Worktree-Merge verloren, wie /partner/my-profile.)"""
|
||||||
|
with db() as conn:
|
||||||
|
profile = conn.execute(
|
||||||
|
"SELECT * FROM breeder_profiles WHERE user_id=?", (user["id"],)
|
||||||
|
).fetchone()
|
||||||
|
if not profile:
|
||||||
|
raise HTTPException(404, "Noch kein Züchter-Profil angelegt.")
|
||||||
|
profile = dict(profile)
|
||||||
|
litters = [dict(r) for r in conn.execute(
|
||||||
|
"SELECT * FROM litters WHERE breeder_id=? ORDER BY created_at DESC",
|
||||||
|
(profile["id"],)
|
||||||
|
).fetchall()]
|
||||||
|
|
||||||
|
# Speicherverbrauch der Züchter-Medien (MEDIA_DIR/breeders/{breeder_id}/**)
|
||||||
|
media_dir = os.getenv("MEDIA_DIR", "/data/media")
|
||||||
|
base = os.path.join(media_dir, "breeders", str(profile["id"]))
|
||||||
|
total = 0
|
||||||
|
if os.path.isdir(base):
|
||||||
|
for root, _dirs, files in os.walk(base):
|
||||||
|
for f in files:
|
||||||
|
try:
|
||||||
|
total += os.path.getsize(os.path.join(root, f))
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return {
|
||||||
|
"profile": profile,
|
||||||
|
"litters": litters,
|
||||||
|
"storage_mb": round(total / (1024 * 1024), 4),
|
||||||
|
"storage_limit_mb": 200,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.put("/breeder/profile")
|
@router.put("/breeder/profile")
|
||||||
async def update_breeder_profile(body: BreederProfileUpdate, user=Depends(require_breeder)):
|
async def update_breeder_profile(body: BreederProfileUpdate, user=Depends(require_breeder)):
|
||||||
with db() as conn:
|
with db() as conn:
|
||||||
|
|
|
||||||
|
|
@ -86,14 +86,14 @@
|
||||||
<title>Ban Yaro</title>
|
<title>Ban Yaro</title>
|
||||||
|
|
||||||
<!-- Theme + theme-color Statusleiste vor CSS setzen -->
|
<!-- Theme + theme-color Statusleiste vor CSS setzen -->
|
||||||
<script src="/js/boot-early.js?v=1266"></script>
|
<script src="/js/boot-early.js?v=1267"></script>
|
||||||
|
|
||||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||||
<link rel="stylesheet" href="/css/design-system.css?v=1266">
|
<link rel="stylesheet" href="/css/design-system.css?v=1267">
|
||||||
<link rel="stylesheet" href="/css/layout.css?v=1266">
|
<link rel="stylesheet" href="/css/layout.css?v=1267">
|
||||||
<link rel="stylesheet" href="/css/components.css?v=1266">
|
<link rel="stylesheet" href="/css/components.css?v=1267">
|
||||||
<link rel="stylesheet" href="/css/utilities.css?v=1266">
|
<link rel="stylesheet" href="/css/utilities.css?v=1267">
|
||||||
<link rel="stylesheet" href="/css/lists.css?v=1266">
|
<link rel="stylesheet" href="/css/lists.css?v=1267">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
@ -620,11 +620,11 @@
|
||||||
<div id="modal-container"></div>
|
<div id="modal-container"></div>
|
||||||
|
|
||||||
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
||||||
<script src="/js/api.js?v=1266"></script>
|
<script src="/js/api.js?v=1267"></script>
|
||||||
<script src="/js/ui.js?v=1266"></script>
|
<script src="/js/ui.js?v=1267"></script>
|
||||||
<script src="/js/app.js?v=1266"></script>
|
<script src="/js/app.js?v=1267"></script>
|
||||||
<script src="/js/worlds.js?v=1266"></script>
|
<script src="/js/worlds.js?v=1267"></script>
|
||||||
<script src="/js/offline-indicator.js?v=1266"></script>
|
<script src="/js/offline-indicator.js?v=1267"></script>
|
||||||
|
|
||||||
<!-- Feature-Seiten werden lazy geladen -->
|
<!-- Feature-Seiten werden lazy geladen -->
|
||||||
|
|
||||||
|
|
@ -634,7 +634,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Boot: Offline-Banner + SW-Registration (extrahiert für CSP) -->
|
<!-- Boot: Offline-Banner + SW-Registration (extrahiert für CSP) -->
|
||||||
<script src="/js/boot.js?v=1266"></script>
|
<script src="/js/boot.js?v=1267"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '1266'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '1267'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
||||||
window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator)
|
window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator)
|
||||||
window.APP_VERSION = APP_VERSION;
|
window.APP_VERSION = APP_VERSION;
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,19 @@ window.Page_breeder_dashboard = (() => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-xs-muted" style="padding:0 var(--space-1)">
|
<!-- Läufigkeit & Trächtigkeit -->
|
||||||
${UI.icon('info')} Läufigkeit & Trächtigkeit findest du wie gewohnt in der HUND-Welt.
|
<div class="card" style="padding:var(--space-4);margin-bottom:var(--space-3)">
|
||||||
|
<div style="display:flex;align-items:center;gap:var(--space-3)">
|
||||||
|
<div style="width:44px;height:44px;border-radius:var(--radius-md);background:rgba(236,72,153,.12);
|
||||||
|
display:flex;align-items:center;justify-content:center;flex-shrink:0">
|
||||||
|
<svg class="ph-icon" style="width:22px;height:22px;color:#EC4899"><use href="/icons/phosphor.svg#thermometer"></use></svg>
|
||||||
|
</div>
|
||||||
|
<div class="flex-1-min">
|
||||||
|
<div style="font-weight:700">Läufigkeit & Trächtigkeit</div>
|
||||||
|
<div class="text-xs-muted">Zyklen, Progesterontests, Deckdaten, Meilensteine</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-sm btn-secondary" data-bd-nav="laeufi">Öffnen</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -573,7 +573,6 @@ window.Worlds = (() => {
|
||||||
{ icon:'certificate', label:'Züchter', page:'breeder-dashboard', role:'breeder',
|
{ icon:'certificate', label:'Züchter', page:'breeder-dashboard', role:'breeder',
|
||||||
fab:[{ icon:'notebook', color:'#10B981', label:'Wurf anlegen', sub:'Neuen Wurf eintragen', page:'litters', action:'openNew' },
|
fab:[{ icon:'notebook', color:'#10B981', label:'Wurf anlegen', sub:'Neuen Wurf eintragen', page:'litters', action:'openNew' },
|
||||||
{ icon:'tree-structure', color:'#8B5CF6', label:'Zuchthund eintragen', sub:'Neuen Hund anlegen', page:'zuchthunde', action:'openNew' }] },
|
{ icon:'tree-structure', color:'#8B5CF6', label:'Zuchthund eintragen', sub:'Neuen Hund anlegen', page:'zuchthunde', action:'openNew' }] },
|
||||||
{ icon:'thermometer', label:'Läufigkeit', page:'laeufi', role:'breeder' },
|
|
||||||
{ icon:'sparkle', label:'Social', page:'social', role:'social',
|
{ icon:'sparkle', label:'Social', page:'social', role:'social',
|
||||||
fab:[{ icon:'sparkle', color:'#EC4899', label:'Social-Post', sub:'Beitrag erstellen', page:'social', action:'openNew' }] },
|
fab:[{ icon:'sparkle', color:'#EC4899', label:'Social-Post', sub:'Beitrag erstellen', page:'social', action:'openNew' }] },
|
||||||
{ icon:'shield-check', label:'Moderation', page:'moderation', role:'mod' },
|
{ icon:'shield-check', label:'Moderation', page:'moderation', role:'mod' },
|
||||||
|
|
@ -589,7 +588,7 @@ window.Worlds = (() => {
|
||||||
const _DEFAULT_CONFIG = {
|
const _DEFAULT_CONFIG = {
|
||||||
jetzt: ['notes','expenses','erste-hilfe','playdate','chat','wetter','social','moderation','partner-dashboard','admin'],
|
jetzt: ['notes','expenses','erste-hilfe','playdate','chat','wetter','social','moderation','partner-dashboard','admin'],
|
||||||
hund: ['diary','health','uebungen','trainingsplaene','adoption','sitting','wiki','wurfboerse',
|
hund: ['diary','health','uebungen','trainingsplaene','adoption','sitting','wiki','wurfboerse',
|
||||||
'breeder-dashboard','laeufi','ernaehrung','personality'],
|
'breeder-dashboard','ernaehrung','personality'],
|
||||||
welt: ['map','forum','friends','walks','poison','recalls','lost','routes','events',
|
welt: ['map','forum','friends','walks','poison','recalls','lost','routes','events',
|
||||||
'jobs','knigge','movies','reise'],
|
'jobs','knigge','movies','reise'],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="color-scheme" content="light dark">
|
<meta name="color-scheme" content="light dark">
|
||||||
<script src="/js/landing-init.js?v=1266"></script>
|
<script src="/js/landing-init.js?v=1267"></script>
|
||||||
<title>Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz</title>
|
<title>Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz</title>
|
||||||
<meta name="description" content="Ban Yaro: Die kostenlose All-in-One Hunde-App für DACH. Tagebuch, Giftköder-Alarm, Training mit KI, Forum, Wurfbörse, Stammbaum, Inzucht-Check — DSGVO-konform, offline-fähig, direkt im Browser.">
|
<meta name="description" content="Ban Yaro: Die kostenlose All-in-One Hunde-App für DACH. Tagebuch, Giftköder-Alarm, Training mit KI, Forum, Wurfbörse, Stammbaum, Inzucht-Check — DSGVO-konform, offline-fähig, direkt im Browser.">
|
||||||
<meta name="keywords" content="Hunde App, Hunde Community, Wurfbörse, Züchter, Welpen kaufen, Stammbaum Hund, Inzuchtkoeffizient, Hundezucht, Impfpass Hund, Giftköder Alarm, Gassi Community, Hundetraining App, Hunde Forum, Hunde KI, Hundefilm Datenbank, Welpen Marktplatz">
|
<meta name="keywords" content="Hunde App, Hunde Community, Wurfbörse, Züchter, Welpen kaufen, Stammbaum Hund, Inzuchtkoeffizient, Hundezucht, Impfpass Hund, Giftköder Alarm, Gassi Community, Hundetraining App, Hunde Forum, Hunde KI, Hundefilm Datenbank, Welpen Marktplatz">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
// ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab
|
// ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab
|
||||||
const VER = '1266';
|
const VER = '1267';
|
||||||
const CACHE_VERSION = `by-v${VER}`;
|
const CACHE_VERSION = `by-v${VER}`;
|
||||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||||
|
|
|
||||||
33
tests/test_breeder_editor.py
Normal file
33
tests/test_breeder_editor.py
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
"""Smoke-Tests fuer den Zuechter-Profil-Editor-Endpoint (/breeder/my-editor)."""
|
||||||
|
|
||||||
|
|
||||||
|
def test_my_editor_requires_breeder(client, user):
|
||||||
|
r = client.get("/api/breeder/my-editor", headers=user["headers"])
|
||||||
|
assert r.status_code == 403
|
||||||
|
|
||||||
|
|
||||||
|
def test_my_editor_without_profile_404(client, admin):
|
||||||
|
"""Admin ohne Zuechterprofil -> klare 404-Meldung statt Frontend-Crash."""
|
||||||
|
r = client.get("/api/breeder/my-editor", headers=admin["headers"])
|
||||||
|
assert r.status_code == 404
|
||||||
|
assert "Profil" in r.json()["detail"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_my_editor_with_profile(client, user):
|
||||||
|
"""Zuechter mit Profil -> profile + litters + storage."""
|
||||||
|
from database import db
|
||||||
|
with db() as conn:
|
||||||
|
uid = conn.execute("SELECT id FROM users WHERE email=?", (user["email"],)).fetchone()["id"]
|
||||||
|
conn.execute("UPDATE users SET rolle='breeder' WHERE id=?", (uid,))
|
||||||
|
conn.execute(
|
||||||
|
"""INSERT INTO breeder_profiles (user_id, zwingername, rasse_text, verein, stadt)
|
||||||
|
VALUES (?,?,?,?,?)""",
|
||||||
|
(uid, "Vom Teststall", "Labrador", "VDH", "Ebersberg")
|
||||||
|
)
|
||||||
|
r = client.get("/api/breeder/my-editor", headers=user["headers"])
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
d = r.json()
|
||||||
|
assert d["profile"]["zwingername"] == "Vom Teststall"
|
||||||
|
assert isinstance(d["litters"], list)
|
||||||
|
assert d["storage_limit_mb"] == 200
|
||||||
|
assert d["storage_mb"] >= 0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue