2020-01-21 06:35:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import lxml.html as lh
|
|
|
|
from django.db import migrations
|
2024-09-08 05:31:24 +00:00
|
|
|
from lxml_html_clean import clean_html
|
2020-01-21 06:35:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
def strip_error_html(apps, schema_editor):
|
2022-05-14 17:57:27 +00:00
|
|
|
Submission = apps.get_model("judge", "Submission")
|
2020-01-21 06:35:58 +00:00
|
|
|
for sub in Submission.objects.filter(error__isnull=False).iterator():
|
|
|
|
if sub.error:
|
|
|
|
sub.error = clean_html(lh.fromstring(sub.error)).text_content()
|
2022-05-14 17:57:27 +00:00
|
|
|
sub.save(update_fields=["error"])
|
2020-01-21 06:35:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2022-05-14 17:57:27 +00:00
|
|
|
("judge", "0090_fix_contest_visibility"),
|
2020-01-21 06:35:58 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(strip_error_html, migrations.RunPython.noop, atomic=True),
|
|
|
|
]
|