From f77847b227dc69458c6366755100e601d0097bd7 Mon Sep 17 00:00:00 2001 From: sea-kelp <66500457+sea-kelp@users.noreply.github.com> Date: Mon, 5 Feb 2024 23:47:08 +0000 Subject: [PATCH] Fix Edit Department form (#401) --- OpenOversight/app/main/views.py | 3 ++- OpenOversight/app/templates/department_add_edit.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenOversight/app/main/views.py b/OpenOversight/app/main/views.py index 02a7bdf14..167882816 100644 --- a/OpenOversight/app/main/views.py +++ b/OpenOversight/app/main/views.py @@ -770,6 +770,7 @@ def edit_department(department_id: int): department.state = form.state.data department.last_updated_by = current_user.id db.session.flush() + if form.jobs.data: new_ranks = [] order = 1 @@ -826,8 +827,8 @@ def edit_department(department_id: int): department_id=department_id, ) ) - db.session.commit() + db.session.commit() flash(f"Department {department.name} in {department.state} edited") return redirect(url_for("main.list_officer", department_id=department.id)) else: diff --git a/OpenOversight/app/templates/department_add_edit.html b/OpenOversight/app/templates/department_add_edit.html index 2c61f5ae9..89709f376 100644 --- a/OpenOversight/app/templates/department_add_edit.html +++ b/OpenOversight/app/templates/department_add_edit.html @@ -35,7 +35,7 @@
Enter ranks in hierarchical order, from lowest to highest rank:
{{ wtf.form_errors(form.jobs, hiddens="only") }}
{% if form.jobs|length > 1 %} - {% for subfield in (form.jobs|rejectattr('data.is_sworn_officer','eq',False)|sort(attribute='data.order')|list) %} + {% for subfield in (form.jobs|sort(attribute='data.order')|list) %}