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
|
@register_setting
|
||||||
class DataletsSettings(BaseSetting):
|
class DataletsSettings(BaseSetting):
|
||||||
feedback_question = models.TextBlock(
|
feedback_question = models.TextField(
|
||||||
help_text='Send us a question')
|
help_text='Send us a question', blank=True)
|
||||||
feedback_status = models.IntegerField(
|
feedback_status = models.IntegerField(
|
||||||
choices=(
|
choices=(
|
||||||
(1, _':-('),
|
(1, ':-('),
|
||||||
(2, _':-|'),
|
(2, ':-|'),
|
||||||
(3, _':-)'),
|
(3, ':-)'),
|
||||||
(4, _':-D'),
|
(4, ':-D'),
|
||||||
), help_text='How are you enjoying Wagtail?'
|
), blank=True, null=True,
|
||||||
|
help_text='How are you enjoying Wagtail?'
|
||||||
)
|
)
|
||||||
feedback_comment = models.TextBlock(
|
feedback_comment = models.TextField(
|
||||||
help_text='Any general feedback')
|
help_text='Any general feedback', blank=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = 'Datalets'
|
verbose_name = 'Datalets'
|
||||||
|
|
||||||
@receiver(pre_save, sender=DataletsSettings)
|
@receiver(pre_save, sender=DataletsSettings)
|
||||||
def handle_save_settings(sender, **kwargs):
|
def handle_save_settings(sender, instance, *args, **kwargs):
|
||||||
send_mail("Response from Wagtail",
|
if instance.feedback_status is not None:
|
||||||
"%d\n--\n%s\n--\n%s" % (
|
send_mail("Response from Wagtail",
|
||||||
sender.feedback_status,
|
"%s\n--\n%s\n--\n%s" % (
|
||||||
sender.feedback_question,
|
str(instance.feedback_status),
|
||||||
sender.feedback_comment,
|
instance.feedback_question,
|
||||||
), "wagtail@datalets.ch",
|
instance.feedback_comment,
|
||||||
[ "support@datalets.ch" ]
|
), "wagtail@datalets.ch",
|
||||||
)
|
[ "support@datalets.ch" ]
|
||||||
|
)
|
||||||
|
instance.feedback_status = None
|
||||||
|
instance.feedback_question = ""
|
||||||
|
instance.feedback_comment = ""
|
||||||
|
|
Loading…
Reference in a new issue