dummy version of request form

This commit is contained in:
gashapwn 2020-11-22 07:42:56 +00:00
parent 4b981c00b9
commit 729c929b7f
2 changed files with 44 additions and 9 deletions

35
app.py
View File

@ -15,17 +15,36 @@ def home2(name):
def success(name): def success(name):
return "welcome %s" % name return "welcome %s" % name
# this is a weird way to do this
# right?
def widg_fun(widg):
if(widg.w_type == "input"):
return "input id=id_%s name=%s type=text></input"%(widg.w_name, widg.w_name)
elif(widg.w_type == "textarea"):
return "textarea cols=40 id=id_%s name=%s rows=10 required=\"\""%(widg.w_name, widg.w_name)
elif(widg.w_type == "check"):
return "input id=id_%s name=%s type=checkbox required=\"\""%(widg.w_name, widg.w_name)
return widg.w_type;
def req(): def req():
class Widg:
def __init__(self, w_name, w_type, w_opt):
self.w_name = w_name
self.w_type = w_type
self.w_opt = w_opt
rt = { rt = {
"username": "bob", "username": Widg("username", "input", None),
"displayname": "bob", "displayname": Widg("displayname", "input", None),
"default to display name?": "no", "prefer display name?": Widg("default_disp", "check", None),
"email for account lockout / registration confirmation (optional)": "fuck no", "email for account lockout / registration confirmation (optional)": Widg("email", "input", None),
"SSH public key": "123", "SSH public key": Widg("pub_key", "textarea", None),
"shell of choice": "/bin/bash", "shell of choice": Widg("shell", "choice", [("bash", "/bin/bash"), ("ksh", "/bin/ksh")]),
"have you read the rules?": "lolyeah" "have you read the rules?": Widg("rule_read", "check", None)
}; };
return render_template("req.html", req_tab = rt)
# uhhh is this how you're supposed to do this?
return render_template("req.html", req_tab = rt, widg_fun = widg_fun)
def login(): def login():
if request.method == "POST": if request.method == "POST":

View File

@ -3,14 +3,30 @@
{%block content%} {%block content%}
<p> <p>
<form action="/req/signup" method="post">
<table> <table>
{% for key, value in req_tab.items() %} {% for key, value in req_tab.items() %}
<tr><td>{{ key }}</td><td>{{ value }}</td></tr> <tr><td>{{ key }}</td><td>
{%if value.w_type != "choice" %}
<{{ widg_fun(value) }}></{{value.w_type}}>
{%elif value.w_type == "choice" %}
<select id="id_{{value.w_name}}" name="{{value.w_name}}" required="">
{% for opt in value.w_opt %}
<option value="{{opt[0]}}">{{opt[1]}}</option>
{% endfor %}
</select>
{% endif %}
</td></tr>
{% endfor %} {% endfor %}
<tr><td><input type="submit" value="sign up"></td></tr>
</table> </table>
</form>
</p> </p>
<p> <p>
<p>
A requested feature is to have to allow users to have a unicode username since unicode allows for more interesting aesthics A requested feature is to have to allow users to have a unicode username since unicode allows for more interesting aesthics
</br> </br>
If you enter a unicode display name, the system will try to display your unicode name when possbile. It will also be your default in terminal prompt, chat and your tilde path If you enter a unicode display name, the system will try to display your unicode name when possbile. It will also be your default in terminal prompt, chat and your tilde path