blob: 7f0278cf19c55c55f2e81fbf51f0625268c7ddbe [file] [log] [blame]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-07 15:49
from __future__ import unicode_literals
import uuid
from django.db import migrations, models
from custos_portal.apps.auth.models import PASSWORD_RESET_EMAIL_TEMPLATE
def default_templates(apps, schema_editor):
EmailTemplate = apps.get_model("custos_portal_auth", "EmailTemplate")
verify_email_template = EmailTemplate(
template_type=PASSWORD_RESET_EMAIL_TEMPLATE,
subject="{{first_name}} {{last_name}} ({{username}}), "
"Reset your password in {{portal_title}}",
body="""
<p>
Dear {{first_name}} {{last_name}},
</p>
<p>
Please click the link below to reset your password. This link is
valid for 24 hours.
</p>
<p><a href="{{url}}">{{url}}</a></p>
<p>If you didn't request to reset your password, just ignore this message.</p>
""".strip())
verify_email_template.save()
def delete_default_templates(apps, schema_editor):
EmailTemplate = apps.get_model("custos_portal_auth", "EmailTemplate")
EmailTemplate.objects.filter(
template_type=PASSWORD_RESET_EMAIL_TEMPLATE).delete()
class Migration(migrations.Migration):
dependencies = [
('custos_portal_auth', '0002_default_email_template'),
]
operations = [
migrations.AlterField(
model_name='emailtemplate',
name='template_type',
field=models.IntegerField(choices=[(1, 'Verify Email Template'), (2, 'New User Email Template'), (3, 'Password Reset Email Template')], primary_key=True, serialize=False),
),
migrations.RunPython(default_templates, reverse_code=delete_default_templates)
]