From 52886d176bc1fc47771063055704ab7239e215eb Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 20 Oct 2025 12:21:02 +0100 Subject: [PATCH] Remove exams column from QuestionTable and add current user as author during question import --- sbas/tables.py | 6 +++--- sbas/views.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sbas/tables.py b/sbas/tables.py index 2d481477..9685b947 100644 --- a/sbas/tables.py +++ b/sbas/tables.py @@ -17,7 +17,7 @@ class QuestionTable(tables.Table): #delete = tables.LinkColumn( # "sbas:question_delete", text="Delete", args=[A("pk")], orderable=False #) - exams = tables.ManyToManyColumn(verbose_name="Exams") + #exams = tables.ManyToManyColumn(verbose_name="Exams") selection = tables.CheckBoxColumn(accessor="pk", orderable=False) @@ -39,12 +39,12 @@ class QuestionTable(tables.Table): "category", "author", ) - sequence = ("view", "stem", "answers", "exams") + sequence = ("view", "stem", "answers")#, "exams") def __init__(self, data=None, *args, **kwargs): super().__init__( data.prefetch_related( - "category", "exams", "author" + "category", "author" ), *args, **kwargs, diff --git a/sbas/views.py b/sbas/views.py index 0cd7c5a2..094617e6 100644 --- a/sbas/views.py +++ b/sbas/views.py @@ -741,6 +741,11 @@ def import_llm_questions(request): elif srcs: q.sources = [str(srcs)] q.save() + # Add current user as author of the imported question + try: + q.author.add(request.user) + except Exception: + logger.exception("Failed to add author for imported question idx=%s", idx) # For each M2M, create missing items if allowed and attach resolved for key, model_cls in ( @@ -906,6 +911,11 @@ def import_llm_confirm(request): elif srcs: q.sources = [str(srcs)] q.save() + # Add current user as author of the imported question + try: + q.author.add(request.user) + except Exception: + logger.exception("Failed to add author for confirmed import idx=%s", idx) for key, model_cls in (("finding", Finding), ("structure", Structure), ("condition", Condition), ("presentation", Presentation), ("subspecialty", Subspecialty)): vals = payload.get(key) or []