messages and email (#1073)
This commit is contained in:
parent
2309875f5b
commit
42cffcd2f7
|
@ -3,11 +3,14 @@
|
|||
xmlns:grok="http://namespaces.zope.org/grok"
|
||||
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
|
||||
xmlns:browser="http://namespaces.zope.org/browser"
|
||||
xmlns:i18n="http://namespaces.zope.org/i18n"
|
||||
i18n_domain="tabellio.contest">
|
||||
|
||||
<!-- Include configuration for dependencies listed in setup.py -->
|
||||
<includeDependencies package="." />
|
||||
|
||||
<i18n:registerTranslations directory="locales" />
|
||||
|
||||
<permission
|
||||
id="tabellio.contest.Manage"
|
||||
title="Contests: Manage Contests"
|
||||
|
|
|
@ -2,7 +2,7 @@ import datetime
|
|||
import random
|
||||
|
||||
from five import grok
|
||||
from zope import schema
|
||||
from zope import component, schema
|
||||
from Acquisition import aq_inner
|
||||
from AccessControl import getSecurityManager
|
||||
from Products.Five.browser import BrowserView
|
||||
|
@ -11,6 +11,9 @@ from Products.CMFCore.utils import getToolByName
|
|||
from plone.directives import form, dexterity
|
||||
from plone.dexterity.utils import createContentInContainer
|
||||
|
||||
from plone.registry.interfaces import IRegistry
|
||||
from tabellio.config.interfaces import ITabellioSettings
|
||||
|
||||
from tabellio.contest.interfaces import MessageFactory as _
|
||||
|
||||
class IContest(form.Schema):
|
||||
|
@ -88,8 +91,10 @@ class Participate(BrowserView):
|
|||
for attr in ('name', 'address', 'zipcode', 'locality', 'phone',
|
||||
'email', 'answer1', 'answer2'):
|
||||
if not self.request.form.get(attr, '').strip():
|
||||
if attr == 'phone': # optional
|
||||
continue
|
||||
self.context.plone_utils.addPortalMessage(
|
||||
_(u'You must fill all fields to participate.'),
|
||||
_('You must fill all fields to participate.'),
|
||||
type='warning')
|
||||
self.request.response.redirect('./')
|
||||
return
|
||||
|
@ -104,8 +109,25 @@ class Participate(BrowserView):
|
|||
object.datetime = datetime.datetime.now()
|
||||
object.ipaddress = self.request._client_addr
|
||||
|
||||
self.sendmail(object.email)
|
||||
|
||||
self.request.response.redirect('./thanks')
|
||||
|
||||
def sendmail(self, mto):
|
||||
urltool = getToolByName(self.context, 'portal_url')
|
||||
portal = urltool.getPortalObject()
|
||||
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
||||
|
||||
send_to_address = portal.getProperty('email_from_address')
|
||||
envelope_from = portal.getProperty('email_from_address')
|
||||
encoding = portal.getProperty('email_charset')
|
||||
|
||||
message = settings.contest_body_email
|
||||
message = message.encode(encoding)
|
||||
|
||||
self.context.MailHost.send(message, mto, envelope_from,
|
||||
subject=settings.contest_subject_email)
|
||||
|
||||
|
||||
class PickWinner(BrowserView):
|
||||
def __call__(self):
|
||||
|
@ -135,4 +157,3 @@ class Manage(BrowserView):
|
|||
elif self.request.form.get('back'):
|
||||
self.request.response.redirect('./')
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
<div tal:replace="structure provider:plone.abovecontentbody" />
|
||||
|
||||
<p>
|
||||
Merci de votre participation !
|
||||
Nous vous remercions pour votre participation qui a bien été
|
||||
enregistrée. Les gagnants seront avertis par courriel.
|
||||
</p>
|
||||
|
||||
<div tal:replace="structure provider:plone.belowcontentbody" />
|
||||
|
|
|
@ -56,7 +56,12 @@
|
|||
</div>
|
||||
|
||||
<div class="participant">
|
||||
<p><label>Nom :</label> <input name="name"/></p>
|
||||
<p class="mention-required">
|
||||
Les champs nom, adresse, code postal, localité et courriel sont
|
||||
obligatoires.
|
||||
</p>
|
||||
|
||||
<p><label>Prénom / Nom :</label> <input name="name"/></p>
|
||||
<p><label>Adresse :</label> <input name="address"/></p>
|
||||
<p><label>Code postal :</label> <input name="zipcode"/></p>
|
||||
<p><label>Localité :</label> <input name="locality"/></p>
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: tabellio.contest 1.0\n"
|
||||
"POT-Creation-Date: 2011-12-01 13:50+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
|
||||
"Last-Translator: Frederic Peters <fpeters@entrouvert.com>\n"
|
||||
"Language-Team: --\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0\n"
|
||||
"Language-Code: fr\n"
|
||||
"Language-Name: French\n"
|
||||
"Preferred-Encodings: utf-8 latin1\n"
|
||||
"Domain: tabellio.contest\n"
|
||||
|
||||
#: ./profiles/default/types/tabellio.contest.contest.xml
|
||||
msgid "A contest"
|
||||
msgstr "Un concours"
|
||||
|
||||
#: ./profiles/default/types/tabellio.contest.participant.xml
|
||||
msgid "A participant to a contest"
|
||||
msgstr "Un participant à un concours"
|
||||
|
||||
#: ./contest.py:140
|
||||
msgid "A winner has been picked."
|
||||
msgstr "Un gagnant a été sélectionné."
|
||||
|
||||
#: ./contest.py:35
|
||||
msgid "Active"
|
||||
msgstr "Actif"
|
||||
|
||||
#: ./participant.py:13
|
||||
msgid "Address"
|
||||
msgstr "Adresse"
|
||||
|
||||
#: ./participant.py:19
|
||||
msgid "Answer 1"
|
||||
msgstr "Première réponse"
|
||||
|
||||
#: ./participant.py:20
|
||||
msgid "Answer 2"
|
||||
msgstr "Seconde réponse"
|
||||
|
||||
#: ./contest.py:24
|
||||
msgid "Answers to first question"
|
||||
msgstr "Réponses à la première question"
|
||||
|
||||
#: ./contest.py:30
|
||||
msgid "Answers to second question"
|
||||
msgstr "Réponses à la seconde question"
|
||||
|
||||
#: ./profiles/default/types/tabellio.contest.contest.xml
|
||||
msgid "Contest"
|
||||
msgstr "Concours"
|
||||
|
||||
#: ./contest.py:27
|
||||
msgid "Correct answer to first question"
|
||||
msgstr "Réponse correcte à la première question"
|
||||
|
||||
#: ./contest.py:33
|
||||
msgid "Correct answer to second question"
|
||||
msgstr "Réponse correcte à la seconde question"
|
||||
|
||||
#: ./participant.py:22
|
||||
msgid "Date/time"
|
||||
msgstr "Date/heure"
|
||||
|
||||
#: ./participant.py:17
|
||||
msgid "Email"
|
||||
msgstr "Courriel"
|
||||
|
||||
#: ./contest.py:23
|
||||
msgid "First question"
|
||||
msgstr "Première question"
|
||||
|
||||
#: ./participant.py:23
|
||||
msgid "IP Address"
|
||||
msgstr "Adresse IP"
|
||||
|
||||
#: ./contest.py:22
|
||||
msgid "Introduction"
|
||||
msgstr "Introduction"
|
||||
|
||||
#: ./participant.py:15
|
||||
msgid "Locality"
|
||||
msgstr "Localité"
|
||||
|
||||
#: ./participant.py:12
|
||||
msgid "Name"
|
||||
msgstr "Prénom/Nom"
|
||||
|
||||
#: ./contest.py:143
|
||||
msgid "No winner could be found."
|
||||
msgstr "Aucun gagnant n'a pu être trouvé."
|
||||
|
||||
#: ./contest.py:25
|
||||
msgid "One answer per line"
|
||||
msgstr "Une réponse par ligne"
|
||||
|
||||
#: ./profiles/default/types/tabellio.contest.participant.xml
|
||||
msgid "Participant"
|
||||
msgstr "Participant"
|
||||
|
||||
#: ./participant.py:16
|
||||
msgid "Phone"
|
||||
msgstr "Téléphone"
|
||||
|
||||
#: ./participant.py:25
|
||||
msgid "Removed"
|
||||
msgstr "Retiré"
|
||||
|
||||
#: ./contest.py:29
|
||||
msgid "Second question"
|
||||
msgstr "Seconde question"
|
||||
|
||||
#: ./contest.py:20
|
||||
msgid "Title"
|
||||
msgstr "Titre"
|
||||
|
||||
#: ./participant.py:26
|
||||
msgid "Winner"
|
||||
msgstr "Gagnant"
|
||||
|
||||
#: ./contest.py:97
|
||||
msgid "You must fill all fields to participate."
|
||||
msgstr "Vous devez compléter tous les champs pour participer."
|
||||
|
||||
#: ./participant.py:14
|
||||
msgid "Zipcode"
|
||||
msgstr "Code postal"
|
||||
|
Reference in New Issue