diff --git a/undercover/routes.py b/undercover/routes.py index 03aeb0a..8b119ea 100644 --- a/undercover/routes.py +++ b/undercover/routes.py @@ -1,5 +1,6 @@ # Copyright Sage Vaillancourt 2021 +import json import os import subprocess import threading @@ -89,6 +90,22 @@ def logout(): @writing_blueprint.route('/', methods=['GET']) def index_get(): + email = session.get('username') + form = CLForm() + if email: + user = db.get_user(email) + letters = db.get_user_letters(user.id) + if len(letters) > 0: + data = json.load(letters[0].contents) + # TODO: Load this data more dynamically + form.company.data = data['company'] + form.body.data = data['body'] + form.closingText.data = data['closingText'] + form.jobAndPronoun.data = data['jobAndPronoun'] + form.mySkills.data = data['mySkills'] + form.skillTypes.data = data['skillTypes'] + form.username.data = data['uesrname'] + return render_template( 'writing.jinja2', form=CLForm(),