[silva.infrae.contact][emi] Added mechanism not to display form ...
[email protected] Fri, 11 Oct 2013 16:10:48 +0200
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: emi
date: Fri Oct 11 16:10:34 2013 +0200
revision: 2:ee69fbe8bd7f in silva.infrae.contact
branch:
details: https://hg.infrae.com/silva.infrae.contact?cmd=changeset;node=ee69fbe8bd7f
modified: src/silva/infrae/contact/configure.zcml src/silva/infrae/contact/contactform.py src/silva/infrae/contact/contactform_templates/contactformtemplate.cpt src/silva/infrae/contact/static/contactform.css
added:
removed:
log: Added mechanism not to display form if already sent. Added fixes to
templace and css.
diffstat:
src/silva/infrae/contact/configure.zcml | 1 +
src/silva/infrae/contact/contactform.py | 3 +++
src/silva/infrae/contact/contactform_templates/contactformtemplate.cpt | 10 ++++------
src/silva/infrae/contact/static/contactform.css | 9 ++++++++-
4 files changed, 16 insertions(+), 7 deletions(-)
diffs (90 lines):
diff -r bad8d0fb147f -r ee69fbe8bd7f src/silva/infrae/contact/configure.zcml
--- a/src/silva/infrae/contact/configure.zcml Wed Oct 09 14:34:50 2013 +0200
+++ b/src/silva/infrae/contact/configure.zcml Fri Oct 11 16:10:34 2013 +0200
@@ -5,6 +5,7 @@
i18n_domain="silva">
<include package="five.grok" />
+ <include package="Products.Silva" />
<!-- Grok package -->
<grok:grok package="." />
diff -r bad8d0fb147f -r ee69fbe8bd7f src/silva/infrae/contact/contactform.py
--- a/src/silva/infrae/contact/contactform.py Wed Oct 09 14:34:50 2013 +0200
+++ b/src/silva/infrae/contact/contactform.py Fri Oct 11 16:10:34 2013 +0200
@@ -86,6 +86,8 @@
grok.implements(IPublicContactForm)
label = u'Contact us'
+ sent = False
+
fields = silvaforms.Fields(IContactFormFields)
fields['name'].htmlAttributes['placeholder'] = _(u'Your full name*')
fields['company'].htmlAttributes['placeholder'] = _(u'Your company name')
@@ -107,6 +109,7 @@
sendmail(self.context, msg, mto='[email protected]',
mfrom='[email protected]', subject=sub)
+ self.sent = True
self.status = _(u'Thank you for your message.')
return silvaforms.SUCCESS
diff -r bad8d0fb147f -r ee69fbe8bd7f src/silva/infrae/contact/contactform_templates/contactformtemplate.cpt
--- a/src/silva/infrae/contact/contactform_templates/contactformtemplate.cpt Wed Oct 09 14:34:50 2013 +0200
+++ b/src/silva/infrae/contact/contactform_templates/contactformtemplate.cpt Fri Oct 11 16:10:34 2013 +0200
@@ -1,5 +1,5 @@
<div id="contactus-wrapper">
-<form action="#" tal:attributes="action request.URL;
+<form action="#" tal:attributes="action python:'%s#contactus-wrapper' % (request.URL);
name form.prefix or None;
id form.prefix or None"
method="post"
@@ -23,12 +23,10 @@
<li> <span tal:replace="error.title" /> </li>
</ul>
</div>
-
+<tal:block tal:condition="not:form.sent">
<div class="fields"
tal:condition="form.fieldWidgets">
<div class="field" tal:repeat="widget form.fieldWidgets">
-
-
<br />
<tal:description tal:condition="widget.description">
<span class="field-description"
@@ -53,6 +51,6 @@
<tal:widget tal:content="structure widget.render()" />
</div>
</div>
-
+</tal:block>
</form>
-</div>
\ No newline at end of file
+</div>
diff -r bad8d0fb147f -r ee69fbe8bd7f src/silva/infrae/contact/static/contactform.css
--- a/src/silva/infrae/contact/static/contactform.css Wed Oct 09 14:34:50 2013 +0200
+++ b/src/silva/infrae/contact/static/contactform.css Fri Oct 11 16:10:34 2013 +0200
@@ -1,7 +1,7 @@
#contactus-wrapper {
color: #fff;
background: #222;
- padding: 10px;
+ padding: 8px;
border: 2px solid #ddd;
margin: 10px 0;
float: left;
@@ -21,5 +21,12 @@
}
#contactus-wrapper h3 {
+ margin: 0;
color: #fff;
+ font-size: 1.3em;
+ line-height: inherit;
}
+
+#contactus-wrapper .actions {
+ margin: 1em;
+}