# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2022-07-21 12:35
from __future__ import unicode_literals

from django.db import migrations
from utils import migration_utils


OLD_DEFAULT_VALUE = 'Dear {{ review_assignment.reviewer.full_name }},<br/><br/>We are requesting that you undertake a review of "{{ article.title }}" in {{ article.journal.name }}.<br/><br/>We would be most grateful for your time as the feedback from our reviewers is of the utmost importance to our editorial decision-making processes.<br/><br/>You can let us know your decision or decline to undertake the review: {{ review_url }} <br/><br/>{{ article_details }}<br/><br/>Regards,<br/>{{ request.user.signature|safe }}'
VARIANT_ONE = 'Dear {{ review_assignment.reviewer.full_name }},<br/><br/>We are requesting that you undertake a review of "{{ article.title }}" in {{ article.journal.name }}.<br/><br/>We would be most grateful for your time as the feedback from our reviewers is of the utmost importance to our editorial decision making processes.<br/><br/>You can let us know your decision or decline to undertake the review: {{ review_url }} <br/><br/>Regards,<br/>{{ request.user.signature|safe }}<br/>{{ article_details }}'
VARIANT_TWO = 'Dear {{ review_assignment.reviewer.full_name }},<br/><br/>We are requesting that you undertake a review of "{{ article.title }}" in {{ article.journal.name }}.<br/><br/>We would be most grateful for your time as the feedback from our reviewers is of the utmost importance to our editorial decision making processes.<br/><br/>You can let us know your decision or decline to undertake the review: {{ review_url }} <br/><br/>Regards,<br/>{{ request.user.signature }}<br/>{{ article_details }}'

NEW_VALUE = 'Dear {{ review_assignment.reviewer.full_name }},<br/><br/>We are requesting that you undertake a review of "{{ article.title }}" in {{ article.journal.name }}.<br/><br/>We would be most grateful for your time as the feedback from our reviewers is of the utmost importance to our editorial decision-making processes.<br/><br/>You can let us know your decision or decline to undertake the review: {{ review_url }} <br/><br/> This review assignment is due on {{ review_assignment.date_due|date:"Y-m-d" }}.  <br/><br/>{{ article_details }}<br/><br/>Regards,<br/>{{ request.user.signature|safe }}'


def update_default_setting(apps, schema_editor):
    migration_utils.update_default_setting_values(
        apps,
        setting_name="review_assignment",
        group_name="email",
        values_to_replace=[OLD_DEFAULT_VALUE, VARIANT_ONE, VARIANT_TWO],
        replacement_value=NEW_VALUE,
    )


class Migration(migrations.Migration):
    dependencies = [
        ("core", "0074_account_suffix"),
    ]

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