# Generated by Django 3.2.20 on 2024-04-17 15:26

from django.db import migrations
from utils import migration_utils


def replace_peer_reviewer_pub_notification(apps, schema_editor):
    values_to_replace = [
        '<p>Dear {{reviewer.full_name}}</p><p>An article that you served as peer reviewer for, "{{ article.safe_title }}", has been set for publication.<br><br>The article will be published on {{ article.date_published }}.<br><br>Regards,',
    ]

    replacement_value = '<p>Dear reviewers,</p><p>An article that you served as peer reviewer for, "{{ article.safe_title }}", has been set for publication.<br><br>The article will be published on {{ article.date_published }}.<br><br>Regards,'

    migration_utils.update_default_setting_values(
        apps,
        setting_name="peer_reviewer_pub_notification",
        group_name="email",
        values_to_replace=values_to_replace,
        replacement_value=replacement_value,
    )


class Migration(migrations.Migration):
    dependencies = [
        ("journal", "0064_journal_default_editorial_team_image"),
    ]

    operations = [
        migrations.RenameField(
            model_name="fixedpubcheckitems",
            old_name="notify_the_author",
            new_name="send_notifications",
        ),
        migrations.RunPython(
            replace_peer_reviewer_pub_notification,
            reverse_code=migrations.RunPython.noop,
        ),
    ]
