Skip to content

Commit

Permalink
updates to contact forms to make them more user friendly on submission
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed May 20, 2015
1 parent 9156780 commit 997b92c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Changelog
5.0b3 (unreleased)
------------------

- updates to contact forms to make them more user friendly on submission
[vangheem]

- include code plugin by default for TinyMCE
[vangheem]

Expand Down
15 changes: 10 additions & 5 deletions Products/CMFPlone/browser/author.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from Products.CMFPlone.utils import getToolByName
from Products.CMFPlone.utils import pretty_title_or_id
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.MailHost.interfaces import IMailHost
from Products.statusmessages.interfaces import IStatusMessage

Expand Down Expand Up @@ -98,20 +97,20 @@ def handle_send(self, action):
)

mail_host = getUtility(IMailHost)
encoding = mail_settings.email_charset
email_charset = self.portal.getProperty('email_charset')

try:
message = self.feedback_template(
self, send_from_address=send_from_address,
sender_id=sender_id, url=referer, subject=subject,
message=message, encoding=encoding
message=message, encoding=email_charset
)

message = message.encode(encoding)
message = message.encode(email_charset)

mail_host.send(
message, send_to_address, envelope_from,
subject=subject, charset=encoding
subject=subject, charset=email_charset
)
except ConflictError:
raise
Expand All @@ -129,6 +128,9 @@ def handle_send(self, action):
_(u'Mail sent.'),
type=u'info'
)
self.request.response.redirect('%s/author/%s' % (
self.portal.absolute_url(),
author or ''))
return


Expand Down Expand Up @@ -251,6 +253,9 @@ def __call__(self):
ISecuritySchema, prefix='plone')
allow_anonymous_view_about = security_settings.allow_anon_views_about

mail_settings = registry.forInterface(IMailSchema, prefix='plone')
self.email_from_address = mail_settings.email_from_address

if self.is_anonymous and not allow_anonymous_view_about:
raise Unauthorized()

Expand Down
2 changes: 2 additions & 0 deletions Products/CMFPlone/browser/contact_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ContactForm(form.Form):

fields = field.Fields(IContactForm)
ignoreContext = True
success = False

def mailhost_is_configured(self):
registry = getUtility(IRegistry)
Expand All @@ -44,6 +45,7 @@ def handle_send(self, action):

self.send_message(data)
self.send_feedback()
self.success = True

def generate_mail(self, variables, encoding='utf-8'):
template = self.context.restrictedTraverse(self.template_mailview)
Expand Down
14 changes: 7 additions & 7 deletions Products/CMFPlone/browser/templates/author.pt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
tal:define="portal_url context/@@plone_portal_state/navigation_root_url;
here_url context/@@plone_context_state/object_url;
portal context/@@plone_portal_state/portal;
email_from_address portal/email_from_address;
email_from_address view/email_from_address;
author view/author;
username view/username">

Expand Down Expand Up @@ -59,6 +59,11 @@

<article id="content">
<!-- Author information -->

<img src=""
alt="User portrait picture"
class="portraitPhoto"
tal:attributes="src portrait/absolute_url" />
<h1 class="documentFirstHeading"
tal:condition="authorinfo/fullname"
tal:content="authorinfo/fullname">
Expand All @@ -80,11 +85,6 @@
i18n:translate="label_edit">Edit</a>
</nav>

<img src=""
alt="User portrait picture"
class="portraitPhoto"
tal:attributes="src portrait/absolute_url" />

<div class="documentDescription"
tal:content="authorinfo/description">
Author description.
Expand Down Expand Up @@ -132,7 +132,7 @@
</a>
</p>

<tal:noemailsetup tal:condition="python:not (email_from_address or isAnon)">
<tal:noemailsetup tal:condition="python:not email_from_address">
<p class="discreet"
i18n:translate="text_no_email_setup">
This site doesn't have a valid email setup, so you cannot use
Expand Down
7 changes: 6 additions & 1 deletion Products/CMFPlone/browser/templates/contact-info.pt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

</div>

<div tal:condition="mailhost_is_configured">
<div tal:condition="python: mailhost_is_configured and not view.success">

<div i18n:translate="description_contact_site_owner" class="documentDescription">
Fill in this form to contact the site owners.
Expand All @@ -42,6 +42,11 @@
</div>

</div>
<div tal:condition="view/success">
<p i18n:translate="description_contact_site_owner_success" class="documentDescription">
Thank you for your feedback
</p>
</div>
</metal:main>
</body>
</html>

0 comments on commit 997b92c

Please sign in to comment.