# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-12-17 10:48
from __future__ import unicode_literals
import re

from django.db import migrations

FROM_RE = re.compile("{{ ?do_review_url ?}}")
TO = "{{ review_url }}"


def replace_setting_urls(apps, schema_editor):
    SettingValueTranslation = apps.get_model('core', 'SettingValueTranslation')
    settings = SettingValueTranslation.objects.filter(master__setting__group__name="email")
    for s in settings:
        fix_url(s)


def fix_url(setting):
    value = setting.value
    new_value = FROM_RE.sub(TO, value)
    setting.value = new_value
    setting.save()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0048_add_article_details_to_review_assignment_email'),
    ]

    operations = [
        migrations.RunPython(replace_setting_urls, reverse_code=migrations.RunPython.noop),
    ]

Fix wrong URL name in review_accept_acknowledgement
Fix wrong URL name in review_accept_acknowledgement
