Settings response
This commit is contained in:
parent
60bdeb2f63
commit
144ffa4c18
3 changed files with 38 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
from .forms import *
|
||||
from .models import *
|
||||
from .snippets import *
|
||||
from .settings import *
|
||||
|
|
36
publichealth/home/models/settings.py
Normal file
36
publichealth/home/models/settings.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.signals import pre_save
|
||||
from django.dispatch import receiver
|
||||
from django.core.mail import send_mail
|
||||
|
||||
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_status = models.IntegerField(
|
||||
choices=(
|
||||
(1, _':-('),
|
||||
(2, _':-|'),
|
||||
(3, _':-)'),
|
||||
(4, _':-D'),
|
||||
), help_text='How are you enjoying Wagtail?'
|
||||
)
|
||||
feedback_comment = models.TextBlock(
|
||||
help_text='Any general feedback')
|
||||
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" ]
|
||||
)
|
|
@ -28,6 +28,7 @@ INSTALLED_APPS = [
|
|||
'wagtail.contrib.wagtailsearchpromotions',
|
||||
'wagtail.contrib.wagtailroutablepage',
|
||||
'wagtail.contrib.wagtailsitemaps',
|
||||
'wagtail.contrib.settings',
|
||||
'wagtail.wagtailforms',
|
||||
'wagtail.wagtailredirects',
|
||||
'wagtail.wagtailembeds',
|
||||
|
|
Loading…
Reference in a new issue