diff --git a/undercover/routes.py b/undercover/routes.py index 79ca386..af6d355 100644 --- a/undercover/routes.py +++ b/undercover/routes.py @@ -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') diff --git a/undercover/templates/writing.jinja2 b/undercover/templates/writing.jinja2 index 9ad8ef1..b2636bd 100644 --- a/undercover/templates/writing.jinja2 +++ b/undercover/templates/writing.jinja2 @@ -63,6 +63,7 @@
{% if username %} {{ render_field(form.letterName, onchange="window.location = '/?letter_name=' + this.options[this.value - 1].label") }} + + {% endif %} {{ render_field(form.username) }} {{ render_field(form.company) }}