Datalets feedback form
This commit is contained in:
parent
144ffa4c18
commit
456ae79ea5
2 changed files with 53 additions and 18 deletions
30
publichealth/home/migrations/0015_dataletssettings.py
Normal file
30
publichealth/home/migrations/0015_dataletssettings.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-04-21 13:13
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0033_auto_20170410_2307'),
|
||||
('home', '0014_auto_20170421_1426'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='DataletsSettings',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('feedback_question', models.TextField(blank=True, help_text='Send us a question')),
|
||||
('feedback_status', models.IntegerField(blank=True, choices=[(1, ':-('), (2, ':-|'), (3, ':-)'), (4, ':-D')], help_text='How are you enjoying Wagtail?', null=True)),
|
||||
('feedback_comment', models.TextField(blank=True, help_text='Any general feedback')),
|
||||
('site', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='wagtailcore.Site')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Datalets',
|
||||
},
|
||||
),
|
||||
]
|
|
@ -9,28 +9,33 @@ from wagtail.contrib.settings.models import BaseSetting, register_setting
|
|||
|
||||
@register_setting
|
||||
class DataletsSettings(BaseSetting):
|
||||
feedback_question = models.TextBlock(
|
||||
help_text='Send us a question')
|
||||
feedback_question = models.TextField(
|
||||
help_text='Send us a question', blank=True)
|
||||
feedback_status = models.IntegerField(
|
||||
choices=(
|
||||
(1, _':-('),
|
||||
(2, _':-|'),
|
||||
(3, _':-)'),
|
||||
(4, _':-D'),
|
||||
), help_text='How are you enjoying Wagtail?'
|
||||
(1, ':-('),
|
||||
(2, ':-|'),
|
||||
(3, ':-)'),
|
||||
(4, ':-D'),
|
||||
), blank=True, null=True,
|
||||
help_text='How are you enjoying Wagtail?'
|
||||
)
|
||||
feedback_comment = models.TextBlock(
|
||||
help_text='Any general feedback')
|
||||
feedback_comment = models.TextField(
|
||||
help_text='Any general feedback', blank=True)
|
||||
class Meta:
|
||||
verbose_name = 'Datalets'
|
||||
|
||||
@receiver(pre_save, sender=DataletsSettings)
|
||||
def handle_save_settings(sender, **kwargs):
|
||||
send_mail("Response from Wagtail",
|
||||
"%d\n--\n%s\n--\n%s" % (
|
||||
sender.feedback_status,
|
||||
sender.feedback_question,
|
||||
sender.feedback_comment,
|
||||
), "wagtail@datalets.ch",
|
||||
[ "support@datalets.ch" ]
|
||||
)
|
||||
def handle_save_settings(sender, instance, *args, **kwargs):
|
||||
if instance.feedback_status is not None:
|
||||
send_mail("Response from Wagtail",
|
||||
"%s\n--\n%s\n--\n%s" % (
|
||||
str(instance.feedback_status),
|
||||
instance.feedback_question,
|
||||
instance.feedback_comment,
|
||||
), "wagtail@datalets.ch",
|
||||
[ "support@datalets.ch" ]
|
||||
)
|
||||
instance.feedback_status = None
|
||||
instance.feedback_question = ""
|
||||
instance.feedback_comment = ""
|
||||
|
|
Loading…
Reference in a new issue