fix: set created_by automatically on MediaWiki import
- Added imported_by parameter to _run_import and _upsert_exercise - Exercises now automatically get created_by set to importing user - Fixes visibility issue where imported exercises were invisible Related: Wiki import - exercise visibility fix
This commit is contained in:
parent
e6ce7e241c
commit
a02df32ce2
|
|
@ -172,6 +172,7 @@ async def execute_import(
|
|||
reimport=body.reimport_existing,
|
||||
dry_run=body.dry_run,
|
||||
limit=body.limit,
|
||||
imported_by=profile_id,
|
||||
)
|
||||
|
||||
return {
|
||||
|
|
@ -269,6 +270,7 @@ async def _run_import(
|
|||
reimport: bool,
|
||||
dry_run: bool,
|
||||
limit: Optional[int],
|
||||
imported_by: int,
|
||||
):
|
||||
"""Hintergrund-Task: Importiert alle Seiten einer Kategorie."""
|
||||
client = SmwClient()
|
||||
|
|
@ -350,7 +352,7 @@ async def _run_import(
|
|||
# Speichern
|
||||
try:
|
||||
if import_type == "exercise":
|
||||
local_id = _upsert_exercise(mapped, reimport)
|
||||
local_id = _upsert_exercise(mapped, reimport, imported_by)
|
||||
elif import_type == "skill":
|
||||
local_id = _upsert_skill(mapped, reimport)
|
||||
else:
|
||||
|
|
@ -445,7 +447,7 @@ def _update_log(
|
|||
conn.commit()
|
||||
|
||||
|
||||
def _upsert_exercise(mapped: dict, reimport: bool) -> Optional[int]:
|
||||
def _upsert_exercise(mapped: dict, reimport: bool, created_by: int) -> Optional[int]:
|
||||
"""Legt Übung an oder aktualisiert sie (wenn reimport=True)."""
|
||||
import json as _json
|
||||
|
||||
|
|
@ -486,8 +488,8 @@ def _upsert_exercise(mapped: dict, reimport: bool) -> Optional[int]:
|
|||
"""INSERT INTO exercises
|
||||
(title, summary, goal, execution, preparation, trainer_notes,
|
||||
duration_min, duration_max, group_size_min, group_size_max,
|
||||
equipment, visibility, status, import_source, import_id)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
|
||||
equipment, visibility, status, import_source, import_id, created_by)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
|
||||
RETURNING id""",
|
||||
(
|
||||
mapped.get("title"), mapped.get("summary"), mapped.get("goal"),
|
||||
|
|
@ -499,6 +501,7 @@ def _upsert_exercise(mapped: dict, reimport: bool) -> Optional[int]:
|
|||
mapped.get("status", "draft"),
|
||||
"mediawiki",
|
||||
mapped.get("import_id"),
|
||||
created_by,
|
||||
)
|
||||
)
|
||||
ex_id = cur.fetchone()['id']
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user