Commit d8984a41706f5657290fd1a57ac1c51c2d8ee8aa
1 parent
1e2b62f0
Exists in
master
and in
3 other branches
Providing initial data to mailsender
Showing
3 changed files
with
49 additions
and
1 deletions
Show diff stats
... | ... | @@ -0,0 +1,13 @@ |
1 | +# coding=utf-8 | |
2 | +from django import forms | |
3 | + | |
4 | +from .models import MailSender | |
5 | + | |
6 | +class MailSenderForm(forms.ModelForm): | |
7 | + | |
8 | + class Meta: | |
9 | + model = MailSender | |
10 | + fields = ['description', 'hostname', 'port', 'username', 'password', 'crypto'] | |
11 | + widgets = { | |
12 | + 'password': forms.PasswordInput(render_value = True) | |
13 | + } | |
0 | 14 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,35 @@ |
1 | +# -*- coding: utf-8 -*- | |
2 | +# Generated by Django 1.10 on 2017-01-06 19:53 | |
3 | +from __future__ import unicode_literals | |
4 | + | |
5 | +from django.db import migrations | |
6 | + | |
7 | +def forwards_func(apps, schema_editor): | |
8 | + # We get the model from the versioned app registry; | |
9 | + # if we directly import it, it'll be the wrong version | |
10 | + MailSender = apps.get_model("mailsender", "MailSender") | |
11 | + | |
12 | + db_alias = schema_editor.connection.alias | |
13 | + | |
14 | + MailSender.objects.using(db_alias).bulk_create([ | |
15 | + MailSender(description="Example", hostname="example.com", port=25, username="example", password="example", crypto=1), | |
16 | + ]) | |
17 | + | |
18 | +def reverse_func(apps, schema_editor): | |
19 | + # forwards_func() creates two Country instances, | |
20 | + # so reverse_func() should delete them. | |
21 | + MailSender = apps.get_model("mailsender", "MailSender") | |
22 | + | |
23 | + db_alias = schema_editor.connection.alias | |
24 | + | |
25 | + MailSender.objects.using(db_alias).filter(description="Example", hostname="example.com", port=25, username="example", password="example", crypto=1).delete() | |
26 | + | |
27 | +class Migration(migrations.Migration): | |
28 | + | |
29 | + dependencies = [ | |
30 | + ('mailsender', '0001_initial'), | |
31 | + ] | |
32 | + | |
33 | + operations = [ | |
34 | + migrations.RunPython(forwards_func, reverse_func), | |
35 | + ] | |
0 | 36 | \ No newline at end of file | ... | ... |
mailsender/views.py