Added a data migration to fix up some incorrect external URLs for reviews.
- Legacy-Id: 17402
This commit is contained in:
parent
89ec88dd7d
commit
638fbc592e
37
ietf/doc/migrations/0030_fix_bytes_mailarch_url.py
Normal file
37
ietf/doc/migrations/0030_fix_bytes_mailarch_url.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Copyright The IETF Trust 2020, All Rights Reserved
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.20 on 2019-05-21 14:27
|
||||
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def forward(apps, schema_editor):
|
||||
|
||||
Document = apps.get_model('doc', 'Document')
|
||||
|
||||
print('')
|
||||
for d in Document.objects.filter(external_url__contains="/b'"):
|
||||
match = re.search("^(%s/arch/msg/[^/]+/)b'([^']+)'$" % settings.MAILING_LIST_ARCHIVE_URL, d.external_url)
|
||||
if match:
|
||||
d.external_url = "%s%s" % (match.group(1), match.group(2))
|
||||
d.save()
|
||||
print('Fixed url #%s: %s' % (d.id, d.external_url))
|
||||
|
||||
def reverse(apps, schema_editor):
|
||||
pass
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('doc', '0029_add_ipr_event_types'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(forward, reverse),
|
||||
]
|
Loading…
Reference in a new issue