From d7a156cf0af43c2ccea31b6432c48235874cd1e1 Mon Sep 17 00:00:00 2001 From: Oliver Marks Date: Thu, 22 Sep 2016 21:35:43 +0100 Subject: [PATCH] fix donate form and token issue --- website/config/settings.py | 9 ++++++ website/pages/__init__.py | 2 +- website/pages/core/authorize.py | 19 ++++++++----- website/pages/donate.py | 13 +++++---- website/widgets/form_simple.py | 49 ++++++++++++++++++++++----------- 5 files changed, 62 insertions(+), 30 deletions(-) diff --git a/website/config/settings.py b/website/config/settings.py index 1388400..038e4da 100644 --- a/website/config/settings.py +++ b/website/config/settings.py @@ -28,6 +28,15 @@ database = { 'db': "maidstone_hackspace", 'port': 3306} +email_server = { + 'username': '', + 'password': '', + 'host': 'mail_server', + 'port': 1025, + 'use_tls': False, + 'from': 'support@maidstone-hackspace.org.uk', + 'to': 'support@maidstone-hackspace.org.uk'} + # secret so not included in default settings oauth_live = False oauth_redirect_uri = app_domain + '/oauth' diff --git a/website/pages/__init__.py b/website/pages/__init__.py index 9901fff..036e1a0 100644 --- a/website/pages/__init__.py +++ b/website/pages/__init__.py @@ -16,7 +16,7 @@ web.template.append(' -
- %s -
- ''' + template = { + 'text':''' +
+
+ %s +
+
''', + 'radio': ''' +

+ %s +

'''} def create(self, action, method='post'): self.action = action @@ -22,38 +27,50 @@ class control(base_widget): if template: control.template = template - def append(self, input_type, input_name, label, values="", classes='validate', disabled='') + def append(self, input_type, input_name, label, values="", input_id=None, classes='validate', placeholder='', disabled=''): if input_type == 'select' and values: if type(values) is not list or tuple: - self.inputs.append("""""" % (input_name, input_name)) + form_control = """""" % ( + input_name, + input_name, + "\n".join(["""""" % (value, value) for value in values])) + + self.apply_template(input_type, form_control) return self if len(values[0]) == 2: - self.inputs.append(""" + form_control = """ """ % ( input_name, input_name, "\n".join(["""""" % (value, item) for value, item in values])) else: - self.inputs.append(""" + form_control = """ """ % ( input_name, input_name, "\n".join(["""""" % (item, item) for item in values])) + + self.apply_template(input_type, form_control) return self - self.inputs.append(""" + form_control = """ """ % ( input_type, input_name, - input_name, + input_id if input_id else '', label, 'disabled="disabled" ' if disabled else '', classes, - value, - input_name, + values, + input_id if input_id else '', label) - ) + self.apply_template(input_type, form_control) + return self + + def apply_template(self, input_type, form_control): + return self.inputs.append( + control.template.get(input_type, "

%s

") % form_control) def render(self): super(control, self).render() @@ -65,5 +82,5 @@ class control(base_widget): """ % ( self.method, self.action, - "\n".join([control.template % input_item for input_item in inputs]) + "\n".join([input_item for input_item in self.inputs]) )