Wiki: Bildrechte-Bestätigung bei Foto-Einreichung (Checkbox + DB + Mod-Badge), SW by-v363
This commit is contained in:
parent
de73c7901e
commit
d603b7bae1
6 changed files with 42 additions and 7 deletions
|
|
@ -173,6 +173,7 @@ async def mod_fotos(user=Depends(require_moderator)):
|
|||
try:
|
||||
rows = conn.execute("""
|
||||
SELECT s.id, s.rasse_slug, s.foto_url, s.created_at,
|
||||
COALESCE(s.rights_confirmed, 0) AS rights_confirmed,
|
||||
u.name AS user_name,
|
||||
r.name AS rasse_name, r.foto_url AS aktuell_foto
|
||||
FROM wiki_foto_submissions s
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import os
|
|||
import shutil
|
||||
import time
|
||||
import logging
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request, UploadFile, File
|
||||
from fastapi import APIRouter, Depends, Form, HTTPException, Query, Request, UploadFile, File
|
||||
from fastapi.responses import JSONResponse
|
||||
from pydantic import BaseModel
|
||||
from database import db
|
||||
|
|
@ -290,6 +290,7 @@ async def quiz_result(
|
|||
async def submit_foto(
|
||||
slug: str,
|
||||
file: UploadFile = File(...),
|
||||
rights_confirmed: int = Form(0),
|
||||
user = Depends(get_current_user),
|
||||
):
|
||||
with db() as conn:
|
||||
|
|
@ -299,6 +300,9 @@ async def submit_foto(
|
|||
if not rasse:
|
||||
raise HTTPException(404, "Rasse nicht gefunden.")
|
||||
|
||||
if not rights_confirmed:
|
||||
raise HTTPException(400, "Bildrechte-Bestätigung fehlt.")
|
||||
|
||||
# Dateiformat prüfen
|
||||
ct = file.content_type or ""
|
||||
if not ct.startswith("image/"):
|
||||
|
|
@ -336,9 +340,9 @@ async def submit_foto(
|
|||
)
|
||||
|
||||
conn.execute("""
|
||||
INSERT INTO wiki_foto_submissions (user_id, rasse_id, foto_url)
|
||||
VALUES (?,?,?)
|
||||
""", (user["id"], rasse["id"], local_url))
|
||||
INSERT INTO wiki_foto_submissions (user_id, rasse_id, foto_url, rights_confirmed)
|
||||
VALUES (?,?,?,?)
|
||||
""", (user["id"], rasse["id"], local_url, 1))
|
||||
|
||||
logger.info(f"Foto-Einreichung: {rasse['name']} von User {user['id']}")
|
||||
return {"ok": True, "foto_url": local_url}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue