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 the /find department sort #1133

Merged
merged 4 commits into from
Nov 8, 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
4 changes: 2 additions & 2 deletions OpenOversight/app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
STATE_CHOICES,
SUFFIX_CHOICES,
)
from OpenOversight.app.utils.db import dept_choices, unit_choices, unsorted_dept_choices
from OpenOversight.app.utils.db import dept_choices, unit_choices
from OpenOversight.app.widgets import BootstrapListWidget, FormFieldWidget


Expand Down Expand Up @@ -102,7 +102,7 @@ class FindOfficerForm(Form):
dept = QuerySelectField(
"dept",
validators=[DataRequired()],
query_factory=unsorted_dept_choices,
query_factory=dept_choices,
get_label="display_name",
)
unit = StringField("unit", default="Not Sure", validators=[Optional()])
Expand Down
10 changes: 2 additions & 8 deletions OpenOversight/app/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
add_department_query,
add_unit_query,
compute_leaderboard_stats,
dept_choices,
unit_choices,
unsorted_dept_choices,
)
from OpenOversight.app.utils.forms import (
add_new_assignment,
Expand Down Expand Up @@ -181,12 +181,6 @@ def browse():
def get_officer():
form = FindOfficerForm()

# TODO: Figure out why this test is failing when the departments are sorted using
# the dept_choices function.
departments_dict = [
dept_choice.to_custom_dict() for dept_choice in unsorted_dept_choices()
]

if getattr(current_user, "dept_pref_rel", None):
set_dynamic_default(form.dept, current_user.dept_pref_rel)

Expand Down Expand Up @@ -217,7 +211,7 @@ def get_officer():
return render_template(
"input_find_officer.html",
form=form,
depts_dict=departments_dict,
depts_dict=[dept_choice.to_custom_dict() for dept_choice in dept_choices()],
jsloads=["js/find_officer.js"],
)

Expand Down
4 changes: 0 additions & 4 deletions OpenOversight/app/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ def dept_choices():
)


def unsorted_dept_choices():
return db.session.query(Department).all()


def get_officer(department_id, star_no, first_name, last_name):
"""
Return the first officer with the given name and badge combo in the department, if one exists.
Expand Down
Loading