[silvatheme.silvacmsorg][Sylvain Viollon] Improve cloud form: ad...
[email protected] Tue, 15 Oct 2013 12:05:48 +0200
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Sylvain Viollon
date: Tue Oct 15 12:05:43 2013 +0200
revision: 723:dbd6a55d033d in silvatheme.silvacmsorg
branch:
details: https://hg.infrae.com/silvatheme.silvacmsorg?cmd=changeset;node=dbd6a55d033d
modified: src/silvatheme/silvacmsorg/cloud.py src/silvatheme/silvacmsorg/templates_silvacmsorg/cloudbooked.pt
added: src/silvatheme/silvacmsorg/templates_silvacmsorg/cloudbooked.pt
removed:
log: Improve cloud form: add some descriptions, improved text. You are
now redirected to a page if you properly submit the form (so this
removes every duplicated email).
diffstat:
src/silvatheme/silvacmsorg/cloud.py | 92 +++++++--
src/silvatheme/silvacmsorg/templates_silvacmsorg/cloudbooked.pt | 8 +
2 files changed, 77 insertions(+), 23 deletions(-)
diffs (142 lines):
diff -r bc5d13cdaea7 -r dbd6a55d033d src/silvatheme/silvacmsorg/cloud.py
--- a/src/silvatheme/silvacmsorg/cloud.py Thu Sep 12 19:39:13 2013 +0200
+++ b/src/silvatheme/silvacmsorg/cloud.py Tue Oct 15 12:05:43 2013 +0200
@@ -1,13 +1,16 @@
+from Products.Silva.mail import sendmail
from five import grok
-from zope import interface, schema
+from silva.core.interfaces import IContainer
+from silva.core.views import views as silvaviews
+from silva.translations import translate as _
from z3c.schema.email import RFC822MailAddress
from zeam.form import silva as silvaforms
-from silva.core.interfaces import IContainer
-from Products.Silva.mail import sendmail
-from silva.translations import translate as _
+from zope import interface, schema
from zope.traversing.browser import absoluteURL
+grok.templatedir('templates_silvacmsorg')
+
TEMPLATE = u"""
You have a new cloud request!
@@ -21,19 +24,60 @@
"""
+class InvalidDomain(Exception):
+
+ def __init__(self, msg):
+ self.msg = msg
+
+ def doc(self):
+ return self.msg
+
+
+def validate_subdomain(value):
+ if not value:
+ return True
+ if '.' in value:
+ raise InvalidDomain("The subdomain cannot contain dots.")
+ if value.startswith('manage_'):
+ raise InvalidDomain("The subdomain cannot start with manage_.")
+ if not value[0].isalnum():
+ raise InvalidDomain("The subdomain need to start with a letter or a digit.")
+ if value in ('silva', 'test'):
+ raise InvalidDomain("This subdomain is reserved and cannot be used.")
+ return True
+
+
class IContactFields(interface.Interface):
"""Describe a comment.
"""
- name = schema.TextLine(title=u"Your name", required=True)
+ name = schema.TextLine(
+ title=u"Your name",
+ description=u"Valid contact informations are required and will " \
+ "verified manually before the creation of your site. We reserve " \
+ "ourself the right not to create or delete the created site in case " \
+ "of invalid information or abuse.",
+ required=True)
company_name = schema.TextLine(
- title=u"Company", required=False, default=u'')
+ title=u"Company",
+ default=u'',
+ required=False)
+ email = RFC822MailAddress(
+ title=u"Email",
+ required=True)
+ telephone = schema.TextLine(
+ title=u"Telephone",
+ default=u'',
+ required=False)
subdomain_name = schema.TextLine(
- title=u"Subdomain", required=True, default=u'')
- email = RFC822MailAddress(title=u"Email", required=True)
- telephone = schema.TextLine(
- title=u"Telephone", required=False, default=u'')
+ title=u"Subdomain",
+ description=u"The subdomain will used in front of cloud.silvacms.org " \
+ "in order to create the domain name of your site.",
+ default=u'',
+ constraint=validate_subdomain,
+ required=True,)
comment = schema.Text(
- title=u"Comment", required=False)
+ title=u"Comment",
+ required=False)
class CloudForm(silvaforms.PublicForm):
@@ -43,13 +87,13 @@
grok.context(IContainer)
label = _(u'Cloud instance')
- description = _(u"""You can request a cloud instance using this form.
- The instance will usually
- be setup in less than a business day.
- Once your instance is setup you'll be sent a URL,
- e.g.: http://yourname.silvacms.org/.
- Then you'll have your own Silva sandbox
- and you can give Silva an extensive test drive.""")
+ description = _(u"""You can request a cloud site using this form.
+ The site will usually be setup in less than a business
+ day. Once it is done you'll be sent a URL, e.g.:
+ http://subdomain.cloud.silvacms.org, a user and password to
+ access your site. Then you'll have your own Silva sandbox and
+ you can give Silva an extensive test drive. There is no
+ guarantee of service on this hosting.""")
fields = silvaforms.Fields(IContactFields)
@silvaforms.action(_(u"Get your cloud instance!"),
@@ -62,9 +106,11 @@
sendmail(self.context, TEMPLATE.format(**data.getDictWithDefault()),
mto='[email protected]', mfrom='[email protected]',
subject='Cloud instance request from silvacms.org')
- success = self.context.get_root()._getOb('success', None)
- if success is not None:
- self.response.redirect(absoluteURL(success, self.request))
- else:
- self.status = _(u'Thank you for your request.')
+ self.response.redirect(
+ absoluteURL(self.context, self.request) + '/cloud-booked.html')
return silvaforms.SUCCESS
+
+
+class CloudBooked(silvaviews.Page):
+ grok.name('cloud-booked.html')
+ grok.context(IContainer)
diff -r bc5d13cdaea7 -r dbd6a55d033d src/silvatheme/silvacmsorg/templates_silvacmsorg/cloudbooked.pt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/silvatheme/silvacmsorg/templates_silvacmsorg/cloudbooked.pt Tue Oct 15 12:05:43 2013 +0200
@@ -0,0 +1,8 @@
+<div>
+ <h1>Cloud site requested</h1>
+ <p>
+ Your cloud site has been requested. If you do not get feedback in
+ two days, please use the <a href="#" tal:attributes="href string:${context/absolute_url}/contact.html">contact form</a> to
+ request a status.
+ </p>
+</div>