diff --git a/tabellio/contact/configure.zcml b/tabellio/contact/configure.zcml
index 23f8dea..5a5b82a 100644
--- a/tabellio/contact/configure.zcml
+++ b/tabellio/contact/configure.zcml
@@ -13,6 +13,12 @@
+
+
diff --git a/tabellio/contact/form.py b/tabellio/contact/form.py
index ba7e710..1773726 100644
--- a/tabellio/contact/form.py
+++ b/tabellio/contact/form.py
@@ -13,6 +13,7 @@ from plone.z3cform.layout import wrap_form
from z3c.form.ptcompat import ViewPageTemplateFile
from plone.dexterity.content import Item
+from Products.Five import BrowserView
from plone.formwidget.captcha.widget import CaptchaFieldWidget
from plone.formwidget.captcha.validator import CaptchaValidator
@@ -50,9 +51,11 @@ class View(grok.View):
def get_possible_subjects(context):
terms = []
for line in context.context.subjects.splitlines():
- try:
+ if line.count('|') == 1:
topic, email = line.strip().split('|')
- except ValueError:
+ elif line.count('|') == 2:
+ topic, email, service = line.strip().split('|')
+ else:
continue
if email == '->deputy':
terms.append(SimpleVocabulary.createTerm('-deputy', '-deputy', topic))
@@ -62,16 +65,33 @@ def get_possible_subjects(context):
terms.append(SimpleVocabulary.createTerm('-', '-', '-'))
return SimpleVocabulary(terms)
-def get_email_for_subject(context, topic):
+def get_email_for_subject(context, selected_topic):
for line in context.context.subjects.splitlines():
- try:
+ if line.count('|') == 1:
topic, email = line.strip().split('|')
- except ValueError:
+ elif line.count('|') == 2:
+ topic, email, service = line.strip().split('|')
+ else:
continue
- if topic == topic:
+ if topic == selected_topic:
return email
return None
+class ServiceView(BrowserView):
+ def __call__(self):
+ selected_topic = self.request.form.get('id')
+ for line in self.context.subjects.splitlines():
+ if line.count('|') == 1:
+ topic, email = line.strip().split('|')
+ elif line.count('|') == 2:
+ topic, email, service = line.strip().split('|')
+ else:
+ continue
+ if selected_topic == topic.encode('ascii', 'replace'):
+ return _(u'Your request will be handled by: %s') % service
+ return None
+
+
class IEffectiveContact(interface.Interface):
subject = schema.Choice(title=_(u'Subject'), required=True,
source=get_possible_subjects)
diff --git a/tabellio/contact/form_templates/view_effectivecontact.pt b/tabellio/contact/form_templates/view_effectivecontact.pt
index a1a5aa5..6daf09f 100644
--- a/tabellio/contact/form_templates/view_effectivecontact.pt
+++ b/tabellio/contact/form_templates/view_effectivecontact.pt
@@ -8,11 +8,15 @@