Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Edit Department form #401

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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