Skip to content

Commit

Permalink
Fix Edit Department form (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-kelp committed Feb 5, 2024
1 parent 7d759d1 commit f77847b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion OpenOversight/app/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion OpenOversight/app/templates/department_add_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h5>Enter ranks in hierarchical order, from lowest to highest rank:</h5>
</div>
<div class="text-danger">{{ wtf.form_errors(form.jobs, hiddens="only") }}</div>
{% 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) %}
<fieldset>
<div class="input-group {% if subfield.errors %} has-error{% endif -%} {%- if subfield.flags.required %} required{% endif -%}">
<div class="input-group-addon">
Expand Down

0 comments on commit f77847b

Please sign in to comment.