Save data to cookies. TODO: read this data
This commit is contained in:
parent
aaa4117e7f
commit
5be8d759c3
14
latty.py
14
latty.py
|
@ -21,8 +21,18 @@ class CLData():
|
||||||
closingtext: str
|
closingtext: str
|
||||||
body: str
|
body: str
|
||||||
|
|
||||||
def define(file, name, data, whitespace=""):
|
def get_pairs():
|
||||||
file.write("\\def \\" + name + "{" + data + whitespace + "}\n")
|
return [
|
||||||
|
("username", username),
|
||||||
|
("company", company),
|
||||||
|
("jobandpronoun", jobandpronoun),
|
||||||
|
("skilltypes", skilltypes),
|
||||||
|
("myskills", myskills),
|
||||||
|
("closingtext", closingtext),
|
||||||
|
("body", body),
|
||||||
|
]
|
||||||
|
|
||||||
|
def define(file, name, data, whitespace=""): file.write("\\def \\" + name + "{" + data + whitespace + "}\n")
|
||||||
|
|
||||||
def generate(data: CLData, unique):
|
def generate(data: CLData, unique):
|
||||||
proj_dir = os.path.dirname(os.getcwd()) + '/undercover/'
|
proj_dir = os.path.dirname(os.getcwd()) + '/undercover/'
|
||||||
|
|
28
writing.py
28
writing.py
|
@ -8,23 +8,6 @@ from latty import (CLData, generate)
|
||||||
|
|
||||||
writing_blueprint = Blueprint('writing', __name__,)
|
writing_blueprint = Blueprint('writing', __name__,)
|
||||||
|
|
||||||
default_defines = [
|
|
||||||
("username", "Sage"),
|
|
||||||
("company", "BananaCorp"),
|
|
||||||
("jobandpronoun", "Banana Stocker"),
|
|
||||||
("skilltypes", "practical"),
|
|
||||||
("myskills", "stocking"),
|
|
||||||
("closingtext", "I am looking forward to hearing from you"),
|
|
||||||
("body", """
|
|
||||||
My name is \\username. I would like to work as \\jobandpronoun with your
|
|
||||||
company. I think my knowledge of \\myskills will contribute well to your
|
|
||||||
team.
|
|
||||||
|
|
||||||
I am passionate about my work, and think we would work well together.
|
|
||||||
|
|
||||||
Thank you for your consideration."""),
|
|
||||||
]
|
|
||||||
|
|
||||||
class CLForm(Form):
|
class CLForm(Form):
|
||||||
username = StringField('Username',
|
username = StringField('Username',
|
||||||
[validators.Length(min=4, max=99)],
|
[validators.Length(min=4, max=99)],
|
||||||
|
@ -78,13 +61,14 @@ def index():
|
||||||
closingtext=form.closingtext.data,
|
closingtext=form.closingtext.data,
|
||||||
body=form.body.data,
|
body=form.body.data,
|
||||||
)
|
)
|
||||||
return generate(data, get_unique())
|
|
||||||
#return send_from_directory(download, unique + ".pdf", as_attachment=True)
|
|
||||||
|
|
||||||
for define in default_defines:
|
resp = generate(data, get_unique())
|
||||||
print("\\def \\" + define[0] + " {xxx}")
|
# Save entered data as cookies on user's machine
|
||||||
|
for pair in data.get_pairs():
|
||||||
|
resp.set_cookie(pair[0], pair[1])
|
||||||
|
return resp
|
||||||
|
|
||||||
return render_template('writing.html',
|
return render_template('writing.html',
|
||||||
form=form,
|
form=form,
|
||||||
unique=get_unique(),
|
unique=get_unique(),
|
||||||
defines=default_defines
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue