16428f2c16
Models, AI assistant, and UI now show diskussionsfertige Antworten without titles; shared search partial fixes aria-label rendering. Co-authored-by: Cursor <cursoragent@cursor.com>
70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
from django.db import migrations, models
|
|
|
|
|
|
def migrate_possible_answer_text(apps, schema_editor):
|
|
PossibleAnswer = apps.get_model('claims', 'PossibleAnswer')
|
|
for obj in PossibleAnswer.objects.all():
|
|
obj.answer = (obj.response or obj.argument or '').strip()
|
|
obj.save(update_fields=['answer'])
|
|
|
|
|
|
def migrate_draft_json(apps, schema_editor):
|
|
ClaimDraft = apps.get_model('claims', 'ClaimDraft')
|
|
for draft in ClaimDraft.objects.all():
|
|
answers = []
|
|
for item in draft.counter_arguments or []:
|
|
if isinstance(item, str):
|
|
text = item.strip()
|
|
else:
|
|
text = (item.get('answer') or item.get('response') or '').strip()
|
|
if text:
|
|
answers.append({'answer': text})
|
|
draft.possible_answers = answers
|
|
draft.save(update_fields=['possible_answers'])
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('claims', '0006_remove_claim_evidence_level_and_more'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RenameModel(
|
|
old_name='CounterArgument',
|
|
new_name='PossibleAnswer',
|
|
),
|
|
migrations.AddField(
|
|
model_name='possibleanswer',
|
|
name='answer',
|
|
field=models.TextField(blank=True, default='', verbose_name='Antwort'),
|
|
),
|
|
migrations.RunPython(migrate_possible_answer_text, migrations.RunPython.noop),
|
|
migrations.RemoveField(
|
|
model_name='possibleanswer',
|
|
name='argument',
|
|
),
|
|
migrations.RemoveField(
|
|
model_name='possibleanswer',
|
|
name='response',
|
|
),
|
|
migrations.AlterModelOptions(
|
|
name='possibleanswer',
|
|
options={
|
|
'ordering': ['id'],
|
|
'verbose_name': 'Mögliche Antwort',
|
|
'verbose_name_plural': 'Mögliche Antworten',
|
|
},
|
|
),
|
|
migrations.AddField(
|
|
model_name='claimdraft',
|
|
name='possible_answers',
|
|
field=models.JSONField(blank=True, default=list, verbose_name='Mögliche Antworten'),
|
|
),
|
|
migrations.RunPython(migrate_draft_json, migrations.RunPython.noop),
|
|
migrations.RemoveField(
|
|
model_name='claimdraft',
|
|
name='counter_arguments',
|
|
),
|
|
]
|