|
|
@ -1,4 +1,5 @@ |
|
|
|
#!/usr/bin/env python |
|
|
|
#!/usr/bin/env python |
|
|
|
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
|
|
|
|
|
# Todo: |
|
|
|
# Todo: |
|
|
|
# |
|
|
|
# |
|
|
@ -30,8 +31,9 @@ import errno |
|
|
|
import logging |
|
|
|
import logging |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
html_header = '''<html> |
|
|
|
html_header = u'''<html> |
|
|
|
<head> |
|
|
|
<head> |
|
|
|
|
|
|
|
<meta charset="UTF-8"> |
|
|
|
<style> |
|
|
|
<style> |
|
|
|
/* Default classes */ |
|
|
|
/* Default classes */ |
|
|
|
.btn {{ color: #FFFFFF; font-weight: bold; font-size: 0.9em; |
|
|
|
.btn {{ color: #FFFFFF; font-weight: bold; font-size: 0.9em; |
|
|
@ -91,13 +93,13 @@ html_header = '''<html> |
|
|
|
<div class="page"> |
|
|
|
<div class="page"> |
|
|
|
''' |
|
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
html_footer = ''' |
|
|
|
html_footer = u''' |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</body> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
</html> |
|
|
|
''' |
|
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
html_list = ''' |
|
|
|
html_list = u'''' |
|
|
|
{header} |
|
|
|
{header} |
|
|
|
<div class="list"> |
|
|
|
<div class="list"> |
|
|
|
{form_list} |
|
|
|
{form_list} |
|
|
@ -105,7 +107,7 @@ html_list = ''' |
|
|
|
{footer} |
|
|
|
{footer} |
|
|
|
''' |
|
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
html_form = ''' |
|
|
|
html_form = u''' |
|
|
|
{header} |
|
|
|
{header} |
|
|
|
<div class="form"> |
|
|
|
<div class="form"> |
|
|
|
<h2 class="form-title">{title}</h2> |
|
|
|
<h2 class="form-title">{title}</h2> |
|
|
@ -124,7 +126,7 @@ html_form = ''' |
|
|
|
{footer} |
|
|
|
{footer} |
|
|
|
''' |
|
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
html_submit_response = ''' |
|
|
|
html_submit_response = u''' |
|
|
|
{header} |
|
|
|
{header} |
|
|
|
<div class="result"> |
|
|
|
<div class="result"> |
|
|
|
<h2 class="result-title">{title}</h2> |
|
|
|
<h2 class="result-title">{title}</h2> |
|
|
@ -635,7 +637,7 @@ class ScriptFormWebApp(WebAppHandler): |
|
|
|
if form_def.allowed_users is not None and \ |
|
|
|
if form_def.allowed_users is not None and \ |
|
|
|
self.username not in form_def.allowed_users: |
|
|
|
self.username not in form_def.allowed_users: |
|
|
|
continue # User is not allowed to run this form |
|
|
|
continue # User is not allowed to run this form |
|
|
|
h_form_list.append(''' |
|
|
|
h_form_list.append(u''' |
|
|
|
<li> |
|
|
|
<li> |
|
|
|
<h2 class="form-title">{title}</h2> |
|
|
|
<h2 class="form-title">{title}</h2> |
|
|
|
<p class="form-description">{description}</p> |
|
|
|
<p class="form-description">{description}</p> |
|
|
@ -656,7 +658,7 @@ class ScriptFormWebApp(WebAppHandler): |
|
|
|
self.send_response(200) |
|
|
|
self.send_response(200) |
|
|
|
self.send_header('Content-type', 'text/html') |
|
|
|
self.send_header('Content-type', 'text/html') |
|
|
|
self.end_headers() |
|
|
|
self.end_headers() |
|
|
|
self.wfile.write(output) |
|
|
|
self.wfile.write(output.encode('utf8')) |
|
|
|
|
|
|
|
|
|
|
|
def h_form(self, form_name, errors={}): |
|
|
|
def h_form(self, form_name, errors={}): |
|
|
|
""" |
|
|
|
""" |
|
|
@ -724,7 +726,7 @@ class ScriptFormWebApp(WebAppHandler): |
|
|
|
field['type']) |
|
|
|
field['type']) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return (''' |
|
|
|
return (u''' |
|
|
|
<li> |
|
|
|
<li> |
|
|
|
<p class="form-field-title">{title}</p> |
|
|
|
<p class="form-field-title">{title}</p> |
|
|
|
<p class="form-field-input">{input} <span class="error">{errors}</span></p> |
|
|
|
<p class="form-field-input">{input} <span class="error">{errors}</span></p> |
|
|
@ -760,7 +762,7 @@ class ScriptFormWebApp(WebAppHandler): |
|
|
|
self.send_response(200) |
|
|
|
self.send_response(200) |
|
|
|
self.send_header('Content-type', 'text/html') |
|
|
|
self.send_header('Content-type', 'text/html') |
|
|
|
self.end_headers() |
|
|
|
self.end_headers() |
|
|
|
self.wfile.write(output) |
|
|
|
self.wfile.write(output.encode('utf8')) |
|
|
|
|
|
|
|
|
|
|
|
def h_submit(self, form_values): |
|
|
|
def h_submit(self, form_values): |
|
|
|
""" |
|
|
|
""" |
|
|
@ -836,7 +838,7 @@ class ScriptFormWebApp(WebAppHandler): |
|
|
|
self.send_response(200) |
|
|
|
self.send_response(200) |
|
|
|
self.send_header('Content-type', 'text/html') |
|
|
|
self.send_header('Content-type', 'text/html') |
|
|
|
self.end_headers() |
|
|
|
self.end_headers() |
|
|
|
self.wfile.write(output) |
|
|
|
self.wfile.write(output.encode('utf8')) |
|
|
|
else: |
|
|
|
else: |
|
|
|
# Form had errors |
|
|
|
# Form had errors |
|
|
|
self.h_form(form_name, form_errors) |
|
|
|
self.h_form(form_name, form_errors) |
|
|
|