@@ -0,0 +1,2741 @@
+from django.db import migrations%0A%0ANOTIFICATION_TYPES = ('user_created',)%0ALANGUAGES = %5B'fi'%5D%0ADEFAULT_LANGUAGE = 'fi'%0A%0AFOOTER_FI = 'T%C3%A4m%C3%A4 on automaattinen viesti Helsingin kaupungin tapahtumarajapinnasta. Viestiin ei voi vastata.%5Cn'%0A%0AHTML_SEPARATOR = '%5Cn%3Cbr/%3E%3Cbr/%3E%5Cn'%0A%0AUSER_CREATED_SUBJECT_FI = %22Uusi k%C3%A4ytt%C3%A4j%C3%A4tunnus luotu - %7B%7B user.date_joined%7Cformat_datetime('fi') %7D%7D%22%0AUSER_CREATED_HTML_BODY_FI = %5C%0A%22%22%22Tapahtumarajapintaan on luotu uusi k%C3%A4ytt%C3%A4j%C3%A4tunnus %7B%7B user.date_joined%7Cformat_datetime('fi') %7D%7D:%0A%3Cbr/%3E%3Cbr/%3E%0A%3Ca href=%22mailto:%7B%7B user.email %7D%7D%22%3E%7B%7B user.email %7D%7D%3C/a%3E%0A%3Cbr/%3E%3Cbr/%3E%0A%3Ca href=%22https://api.hel.fi/linkedevents/admin/django_orghierarchy/organization/%22%3ESiirry k%C3%A4ytt%C3%A4jien hallintaan %C2%BB%3C/a%3E%22%22%22%0A%0A%0Adef _append_footer(text, language, separator):%0A    var_name = 'FOOTER_%7B%7D'.format(language).upper()%0A    footer = globals().get(var_name)%0A    assert footer, '%7B%7D undefined'.format(var_name)%0A    return separator.join(%5Btext, footer%5D)%0A%0A%0Adef _get_text(notification_type, language, field):%0A    var_name = '%7B%7D_%7B%7D_%7B%7D'.format(notification_type, field, language).upper()%0A    text = globals().get(var_name)%0A    assert text, '%7B%7D undefined'.format(var_name)%0A    return text%0A%0A%0Adef create_existing_notifications(NotificationTemplate):%0A    for notification_type in NOTIFICATION_TYPES:%0A        subject = _get_text(notification_type, DEFAULT_LANGUAGE, 'subject')%0A        html_body = _get_text(notification_type, DEFAULT_LANGUAGE, 'html_body')%0A        html_body = _append_footer(html_body, DEFAULT_LANGUAGE, HTML_SEPARATOR)%0A        try:%0A            notification = NotificationTemplate.objects.get(type=notification_type)%0A            continue%0A        except NotificationTemplate.DoesNotExist:%0A            pass%0A        notification, created = NotificationTemplate.objects.get_or_create(%0A            type=notification_type,%0A            subject=subject,%0A            html_body=html_body)%0A        if created:%0A            for language in LANGUAGES:%0A                subject = _get_text(notification_type, language, 'subject')%0A                html_body = _get_text(notification_type, language, 'html_body')%0A                html_body = _append_footer(html_body, language, HTML_SEPARATOR)%0A                setattr(notification, 'subject_%7B%7D'.format(language), subject)%0A                setattr(notification, 'html_body_%7B%7D'.format(language), html_body)%0A            notification.save()%0A%0A%0Adef forwards(apps, schema_editor):%0A    NotificationTemplate = apps.get_model('notifications', 'NotificationTemplate')%0A    create_existing_notifications(NotificationTemplate)%0A%0A%0Aclass Migration(migrations.Migration):%0A%0A    dependencies = %5B%0A        ('notifications', '0002_create_default_templates'),%0A    %5D%0A%0A    operations = %5B%0A        migrations.RunPython(forwards, migrations.RunPython.noop)%0A    %5D%0A

Add migration to create "user created" template