fix donate form and token issue
This commit is contained in:
parent
dd28cbe373
commit
d7a156cf0a
|
@ -28,6 +28,15 @@ database = {
|
||||||
'db': "maidstone_hackspace",
|
'db': "maidstone_hackspace",
|
||||||
'port': 3306}
|
'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
|
# secret so not included in default settings
|
||||||
oauth_live = False
|
oauth_live = False
|
||||||
oauth_redirect_uri = app_domain + '/oauth'
|
oauth_redirect_uri = app_domain + '/oauth'
|
||||||
|
|
|
@ -16,7 +16,7 @@ web.template.append('<link rel="icon" type="image/png" href="/static/images/icon
|
||||||
#paths
|
#paths
|
||||||
web.document_root = os.path.abspath('./')
|
web.document_root = os.path.abspath('./')
|
||||||
web.template.domain = 'https://maidstone-hackspace.org.uk/'
|
web.template.domain = 'https://maidstone-hackspace.org.uk/'
|
||||||
web.template.theme_full_path = os.path.abspath('./static') + os.sep
|
# web.template.theme_full_path = os.path.abspath('./static') + os.sep
|
||||||
#~ domain = 'http://192.168.21.41:5000/'
|
#~ domain = 'http://192.168.21.41:5000/'
|
||||||
#~ image_path = domain + os.sep + 'images' + os.sep
|
#~ image_path = domain + os.sep + 'images' + os.sep
|
||||||
|
|
||||||
|
|
|
@ -80,15 +80,20 @@ def load_user(userid):
|
||||||
|
|
||||||
|
|
||||||
@login_manager.token_loader
|
@login_manager.token_loader
|
||||||
def load_token(request):
|
def load_token(token):
|
||||||
|
print('request')
|
||||||
|
print(request)
|
||||||
token = request.headers.get('Authorization')
|
token = request.headers.get('Authorization')
|
||||||
if token is None:
|
if token is None:
|
||||||
token = request.args.get('token')
|
token = request.args.get('token')
|
||||||
|
|
||||||
if token is not None:
|
if token is None:
|
||||||
|
return None
|
||||||
username, password = token.split(":") # naive token
|
username, password = token.split(":") # naive token
|
||||||
user_entry = User.get(username)
|
user_entry = User.get(username)
|
||||||
if (user_entry is not None):
|
if (user_entry is None):
|
||||||
|
return None
|
||||||
|
|
||||||
user = User(user_entry[0], user_entry[1])
|
user = User(user_entry[0], user_entry[1])
|
||||||
|
|
||||||
if (user.password == password):
|
if (user.password == password):
|
||||||
|
|
|
@ -33,12 +33,13 @@ def index():
|
||||||
#~ web.page.section(web.paragraph.render())
|
#~ web.page.section(web.paragraph.render())
|
||||||
|
|
||||||
|
|
||||||
web.form.create('Donate to Maidstone Hackspace', '/donate/submit')
|
web.form_simple.create('Donate to Maidstone Hackspace', '/donate/submit')
|
||||||
web.form.append(name='provider', label='GoCardless', placeholder='gocardless', value='gocardless', input_type='radio')
|
web.form_simple.append(input_name='provider', input_id="choose_gocardless",label='GoCardless', placeholder='gocardless', values='gocardless', input_type='radio')
|
||||||
web.form.append(name='provider', label='PayPal', placeholder='', value='paypal', input_type='radio')
|
web.form_simple.append(input_name='provider', input_id="choose_paypal",label='PayPal', placeholder='', values='paypal', input_type='radio')
|
||||||
web.form.append(name='reference', label='Reference', placeholder='#lair', value='#lair', input_type='select')
|
web.form_simple.append(input_name='provider', input_id="choose_braintree",label='Braintree', placeholder='', values='braintree', input_type='radio')
|
||||||
web.form.append(name='amount', label='Donation Amount', placeholder='50.00', value='50.00')
|
web.form_simple.append(input_name='reference', label='Reference', placeholder='#lair', values=['#lair','#t-shirt'], input_type='select')
|
||||||
web.page.append(web.form.render())
|
web.form_simple.append(input_name='amount', label='Donation Amount', placeholder='50.00', values='50.00', input_type='text')
|
||||||
|
web.page.append(web.form_simple.render())
|
||||||
|
|
||||||
web.template.body.append(web.page.set_classes('page col s10 offset-s1').render())
|
web.template.body.append(web.page.set_classes('page col s10 offset-s1').render())
|
||||||
return web.render()
|
return web.render()
|
||||||
|
|
|
@ -5,12 +5,17 @@ class control(base_widget):
|
||||||
method = 'post'
|
method = 'post'
|
||||||
action = '/'
|
action = '/'
|
||||||
inputs = []
|
inputs = []
|
||||||
template = '''
|
template = {
|
||||||
|
'text':'''
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
%s
|
%s
|
||||||
</div>
|
</div>
|
||||||
</div>'''
|
</div>''',
|
||||||
|
'radio': '''
|
||||||
|
<p>
|
||||||
|
%s
|
||||||
|
</p>'''}
|
||||||
|
|
||||||
def create(self, action, method='post'):
|
def create(self, action, method='post'):
|
||||||
self.action = action
|
self.action = action
|
||||||
|
@ -22,38 +27,50 @@ class control(base_widget):
|
||||||
if template:
|
if template:
|
||||||
control.template = 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 input_type == 'select' and values:
|
||||||
if type(values) is not list or tuple:
|
if type(values) is not list or tuple:
|
||||||
self.inputs.append("""<select name="%s" id="%s">%s</select>""" % (input_name, input_name))
|
form_control = """<select name="%s" id="%s">%s</select>""" % (
|
||||||
|
input_name,
|
||||||
|
input_name,
|
||||||
|
"\n".join(["""<option value="%s">%s</option>""" % (value, value) for value in values]))
|
||||||
|
|
||||||
|
self.apply_template(input_type, form_control)
|
||||||
return self
|
return self
|
||||||
if len(values[0]) == 2:
|
if len(values[0]) == 2:
|
||||||
self.inputs.append("""
|
form_control = """
|
||||||
<select name="%s" id="%s">%s</select>""" % (
|
<select name="%s" id="%s">%s</select>""" % (
|
||||||
input_name,
|
input_name,
|
||||||
input_name,
|
input_name,
|
||||||
"\n".join(["""<option value="%s">%s</option>""" % (value, item) for value, item in values]))
|
"\n".join(["""<option value="%s">%s</option>""" % (value, item) for value, item in values]))
|
||||||
else:
|
else:
|
||||||
self.inputs.append("""
|
form_control = """
|
||||||
<select name="%s" id="%s">%s</select>""" % (
|
<select name="%s" id="%s">%s</select>""" % (
|
||||||
input_name,
|
input_name,
|
||||||
input_name,
|
input_name,
|
||||||
"\n".join(["""<option value="%s">%s</option>""" % (item, item) for item in values]))
|
"\n".join(["""<option value="%s">%s</option>""" % (item, item) for item in values]))
|
||||||
|
|
||||||
|
self.apply_template(input_type, form_control)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
self.inputs.append("""
|
form_control = """
|
||||||
<input type="%s" name="%s" id="%s" placeholder="%s" %s classes="%s" value="%s" />
|
<input type="%s" name="%s" id="%s" placeholder="%s" %s classes="%s" value="%s" />
|
||||||
<label for="%s">%s</label>""" % (
|
<label for="%s">%s</label>""" % (
|
||||||
input_type,
|
input_type,
|
||||||
input_name,
|
input_name,
|
||||||
input_name,
|
input_id if input_id else '',
|
||||||
label,
|
label,
|
||||||
'disabled="disabled" ' if disabled else '',
|
'disabled="disabled" ' if disabled else '',
|
||||||
classes,
|
classes,
|
||||||
value,
|
values,
|
||||||
input_name,
|
input_id if input_id else '',
|
||||||
label)
|
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, "<p>%s</p>") % form_control)
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
super(control, self).render()
|
super(control, self).render()
|
||||||
|
@ -65,5 +82,5 @@ class control(base_widget):
|
||||||
</div>""" % (
|
</div>""" % (
|
||||||
self.method,
|
self.method,
|
||||||
self.action,
|
self.action,
|
||||||
"\n".join([control.template % input_item for input_item in inputs])
|
"\n".join([input_item for input_item in self.inputs])
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue