Don't create a new letter every time.

This commit is contained in:
Sage Vaillancourt 2022-09-25 03:02:52 +00:00
parent 2807c72740
commit 98e385376c
1 changed files with 7 additions and 4 deletions

View File

@ -184,11 +184,14 @@ def index_post():
if email:
user = db.get_user(email)
letters = db.get_user_letters(user.id)
if True: # len(letters) == 0:
db.add_letter(user.id, 'LETTER_TITLE', jsonify(data).get_data(True))
letter_json = jsonify(data).get_data(True)
if len(letters) == 0:
db.add_letter(user.id, 'LETTER_TITLE', letter_json)
else:
print("TODO: Add letter editing!")
# db.edit_letter()
# TODO: Add letter editing!
# For now, edit just the one existing letter
letter = letters[0]
db.edit_letter(letter.id, letter.title, letter_json)
(resp, errors) = data.generate_pdf()
if errors: