Save data to cookies. TODO: read this data

This commit is contained in:
Sage Vaillancourt 2021-07-24 00:26:44 -04:00
parent aaa4117e7f
commit 5be8d759c3
2 changed files with 18 additions and 24 deletions

View File

@ -21,8 +21,18 @@ class CLData():
closingtext: str
body: str
def define(file, name, data, whitespace=""):
file.write("\\def \\" + name + "{" + data + whitespace + "}\n")
def get_pairs():
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):
proj_dir = os.path.dirname(os.getcwd()) + '/undercover/'

View File

@ -8,23 +8,6 @@ from latty import (CLData, generate)
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):
username = StringField('Username',
[validators.Length(min=4, max=99)],
@ -78,13 +61,14 @@ def index():
closingtext=form.closingtext.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:
print("\\def \\" + define[0] + " {xxx}")
resp = generate(data, get_unique())
# 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',
form=form,
unique=get_unique(),
defines=default_defines
)