Skip to content

Commit 638fbc5

Browse files
committed
Added a data migration to fix up some incorrect external URLs for reviews.
- Legacy-Id: 17402
1 parent 89ec88d commit 638fbc5

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright The IETF Trust 2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
# Generated by Django 1.11.20 on 2019-05-21 14:27
4+
5+
6+
from __future__ import absolute_import, print_function, unicode_literals
7+
8+
import re
9+
10+
from django.conf import settings
11+
from django.db import migrations
12+
13+
14+
def forward(apps, schema_editor):
15+
16+
Document = apps.get_model('doc', 'Document')
17+
18+
print('')
19+
for d in Document.objects.filter(external_url__contains="/b'"):
20+
match = re.search("^(%s/arch/msg/[^/]+/)b'([^']+)'$" % settings.MAILING_LIST_ARCHIVE_URL, d.external_url)
21+
if match:
22+
d.external_url = "%s%s" % (match.group(1), match.group(2))
23+
d.save()
24+
print('Fixed url #%s: %s' % (d.id, d.external_url))
25+
26+
def reverse(apps, schema_editor):
27+
pass
28+
29+
class Migration(migrations.Migration):
30+
31+
dependencies = [
32+
('doc', '0029_add_ipr_event_types'),
33+
]
34+
35+
operations = [
36+
migrations.RunPython(forward, reverse),
37+
]

0 commit comments

Comments
 (0)