from django.db import migrations


PLAIN_TEXT_BODY = """Dear User,

Use the following One-Time Password (OTP) to complete your verification:

{otp}

This code expires in 10 minutes.
If you did not request this, please ignore this email.

Wile Security Team
"""


HTML_BODY = """
<html>
<body style="font-family: Arial; background:#f4f7fb; padding:40px;">
    <div style="max-width:500px; margin:auto; background:#fff; padding:30px; border-radius:10px;">
        <h2 style="color:#0f766e;">Wile Verification</h2>

        <p>Dear User,</p>

        <p>Use the following OTP to complete your verification:</p>

        <h1 style="letter-spacing:6px; text-align:center;">{otp}</h1>

        <p>This code expires in 10 minutes.</p>

        <p>If you did not request this, please ignore this email.</p>

        <p><strong>Wile Security Team</strong></p>
    </div>
</body>
</html>
"""


def forwards(apps, schema_editor):
    EmailTemplateTranslation = apps.get_model(
        "notification_engine",
        "EmailTemplateTranslation"
    )

    EmailTemplateTranslation.objects.all().update(
        text_message=PLAIN_TEXT_BODY,
        html_message=HTML_BODY,
    )


def backwards(apps, schema_editor):
    pass


class Migration(migrations.Migration):

    dependencies = [
        ("notification_engine", "0003_update_email_templates"),  # <-- FIX THIS
    ]

    operations = [
        migrations.RunPython(forwards, backwards),
    ]