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) %}