Add sources JSONField to Question model and update import functions to handle source references
This commit is contained in:
@@ -737,6 +737,12 @@ def import_llm_questions(request):
|
||||
q.best_answer = payload.get("best_answer")
|
||||
if cat_obj:
|
||||
q.category = cat_obj
|
||||
# populate sources JSONField if provided (accept list or single string)
|
||||
srcs = payload.get("sources")
|
||||
if isinstance(srcs, list):
|
||||
q.sources = srcs
|
||||
elif srcs:
|
||||
q.sources = [str(srcs)]
|
||||
q.save()
|
||||
|
||||
# For each M2M, create missing items if allowed and attach resolved
|
||||
@@ -871,6 +877,12 @@ def import_llm_confirm(request):
|
||||
if isinstance(cat_val, str):
|
||||
cat_obj, _ = Category.objects.get_or_create(category=cat_val)
|
||||
q.category = cat_obj
|
||||
# populate sources JSONField if provided (accept list or single string)
|
||||
srcs = payload.get("sources")
|
||||
if isinstance(srcs, list):
|
||||
q.sources = srcs
|
||||
elif srcs:
|
||||
q.sources = [str(srcs)]
|
||||
q.save()
|
||||
|
||||
for key, model_cls in (("finding", Finding), ("structure", Structure), ("condition", Condition), ("presentation", Presentation), ("subspecialty", Subspecialty)):
|
||||
|
||||
Reference in New Issue
Block a user