Start sketching out add-letter button.

This commit is contained in:
Sage Vaillancourt 2022-09-29 07:57:13 -04:00
parent b86db5c479
commit a5704c8c12
2 changed files with 11 additions and 0 deletions

View File

@ -125,6 +125,16 @@ def logout() -> Response:
return redirect('/')
@writing_blueprint.route('/add_letter')
def add_letter(user: db.User) -> Response:
# TODO: Add new letter to db
existing_letter_count = len(db.get_user_letters(user.id))
new_letter_name = f'Letter{existing_letter_count + 2}'
default_form_json = jsonify(CLForm().to_cl_data()).get_data(True)
db.add_letter(user.id, new_letter_name, default_form_json)
return redirect(f'/?letter_name={new_letter_name}')
@writing_blueprint.route('/', methods=['GET'])
def index_get() -> Response:
email_address = session.get('username')

View File

@ -63,6 +63,7 @@
<dl>
{% if username %}
{{ render_field(form.letterName, onchange="window.location = '/?letter_name=' + this.options[this.value - 1].label") }}
<span style="background-color: green; color: white;">+</span>
{% endif %}
{{ render_field(form.username) }}
{{ render_field(form.company) }}