From 8fbaf6e369f97d9f92f8e4fe04e1e08fcd91717a Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sat, 24 Sep 2022 17:39:10 -0400 Subject: [PATCH] Try to pull form filling from database, where possible. --- undercover/routes.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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(),