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

Add filter by photo ability in officer query #965

Merged
merged 32 commits into from
Jul 12, 2023
Merged

Conversation

michplunkett
Copy link
Collaborator

@michplunkett michplunkett commented Jul 10, 2023

Fixes issue

#798

Description of Changes

Add the ability for the user to filter officers by the availability of a photo, format the list_officer.html file using djlint, correct carrot behavior on officer search, center displayed officer photos, and update relevant test case.

Screenshots (if appropriate)

Images on the search page are now centered (laptop screen):
Screenshot 2023-07-11 at 12 18 34 PM

Images on the search page are now centered (phone screen):
Screenshot 2023-07-11 at 12 18 45 PM

The carrots 🥕 now respond correctly when their respective menus are opened:
URL: http://localhost:3000/department/1?last_name=&first_name=&badge=&min_age=16&max_age=85&unique_internal_identifier=&require_photo=True&submit=Submit
Screenshot 2023-07-11 at 2 21 50 PM

Tests and linting

  • This branch is up-to-date with the develop branch.
  • pytest passes on my local development environment.
  • pre-commit passes on my local development environment.

@michplunkett michplunkett self-assigned this Jul 10, 2023
@michplunkett michplunkett linked an issue Jul 10, 2023 that may be closed by this pull request
2 tasks
Comment on lines +508 to +513
@media all and (min-width: 768px) and (max-width: 991px) {
.filter-sidebar > .form > .btn.btn-primary:first-of-type {
margin-bottom: 5px;
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before media query:
Screenshot 2023-07-10 at 1 48 23 PM

After media query:
Screenshot 2023-07-10 at 1 48 34 PM

Comment on lines -581 to +592
min-width: 200px;
min-height: 200px;
height: 300px;
Copy link
Collaborator Author

@michplunkett michplunkett Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the previous setup you got these HUGE photos that threw off the flow of the page, so I set a standard height so that the width is automatically set according to its respective aspect ratio.

Comment on lines -348 to -353
officer_query = (
return (
officer_query.outerjoin(Face)
.order_by(Face.officer_id.asc())
.order_by(Officer.id.desc())
)
return officer_query
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary variable assignment.

Comment on lines +743 to +747
# Filter officers by presence of a photo
if form_data["require_photo"]:
officers = officers.join(Face)
else:
officers = officers.options(selectinload(Officer.face))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Picture filtering logic.

This reverts commit 6468e2d.
@michplunkett michplunkett marked this pull request as ready for review July 11, 2023 17:28
@michplunkett michplunkett mentioned this pull request Jul 11, 2023
2 tasks
@michplunkett michplunkett linked an issue Jul 11, 2023 that may be closed by this pull request
@michplunkett
Copy link
Collaborator Author

I linted the HTML file so that it's easier to merge in the formatting PR next.

Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic! Can't wait to add it to our own instance, great stuff 😄 🎉

OpenOversight/app/main/views.py Outdated Show resolved Hide resolved
OpenOversight/tests/routes/test_officer_and_department.py Outdated Show resolved Hide resolved
@b-meson
Copy link
Member

b-meson commented Jul 12, 2023

I haven't built the project and ran it with this diff but the code itself looks good to me.

@michplunkett michplunkett merged commit 6f03a78 into develop Jul 12, 2023
@michplunkett michplunkett deleted the filter_by_photo branch July 12, 2023 16:59
Comment on lines +1678 to +1686
def normalize_tokens_for_comparison(html_str: str, split_str: str):
"""Remove new lines, leading, and closing spaces between <dd> elements in
formatted HTML."""
parsed_list = html_str.data.decode(ENCODING_UTF_8).split(split_str)[1:]
parsed_list = [re.sub(r"<dd>\n\s+", "<dd>", token) for token in parsed_list]
parsed_list = [
re.sub(r"\n\s+</dd>", "</dd>", token) for token in parsed_list
]
return parsed_list
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses the problem that with the newly formatted HTML have a starting line break and A LOT of spaces between the <dd> elements.

@todrobbins
Copy link

Thank you for working on this @michplunkett! Looks terrific.

sea-kelp pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Sep 6, 2023
lucyparsons#798

Add the ability for the user to filter officers by the availability of a
photo, format the `list_officer.html` file using
[`djlint`](https://www.djlint.com/), correct carrot behavior on officer
search, center displayed officer photos, and update relevant test case.

Images on the search page are now centered (laptop screen):
<img width="1469" alt="Screenshot 2023-07-11 at 12 18 34 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/2ee9a10d-9f3c-40ad-be19-9f43442cc9f5">

Images on the search page are now centered (phone screen):
<img width="621" alt="Screenshot 2023-07-11 at 12 18 45 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/3b318ee1-78c0-45ad-af92-f807188adb2d">

The carrots 🥕 now respond correctly when their respective menus are
opened:
URL:
`http://localhost:3000/department/1?last_name=&first_name=&badge=&min_age=16&max_age=85&unique_internal_identifier=&require_photo=True&submit=Submit`
<img width="1470" alt="Screenshot 2023-07-11 at 2 21 50 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/d73b2c68-93ae-46b4-ad94-14666608fe56">

 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.
sea-kelp pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Sep 25, 2023
lucyparsons#798

Add the ability for the user to filter officers by the availability of a
photo, format the `list_officer.html` file using
[`djlint`](https://www.djlint.com/), correct carrot behavior on officer
search, center displayed officer photos, and update relevant test case.

Images on the search page are now centered (laptop screen):
<img width="1469" alt="Screenshot 2023-07-11 at 12 18 34 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/2ee9a10d-9f3c-40ad-be19-9f43442cc9f5">

Images on the search page are now centered (phone screen):
<img width="621" alt="Screenshot 2023-07-11 at 12 18 45 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/3b318ee1-78c0-45ad-af92-f807188adb2d">

The carrots 🥕 now respond correctly when their respective menus are
opened:
URL:
`http://localhost:3000/department/1?last_name=&first_name=&badge=&min_age=16&max_age=85&unique_internal_identifier=&require_photo=True&submit=Submit`
<img width="1470" alt="Screenshot 2023-07-11 at 2 21 50 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/d73b2c68-93ae-46b4-ad94-14666608fe56">

 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.
sea-kelp pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Oct 5, 2023
lucyparsons#798

Add the ability for the user to filter officers by the availability of a
photo, format the `list_officer.html` file using
[`djlint`](https://www.djlint.com/), correct carrot behavior on officer
search, center displayed officer photos, and update relevant test case.

Images on the search page are now centered (laptop screen):
<img width="1469" alt="Screenshot 2023-07-11 at 12 18 34 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/2ee9a10d-9f3c-40ad-be19-9f43442cc9f5">

Images on the search page are now centered (phone screen):
<img width="621" alt="Screenshot 2023-07-11 at 12 18 45 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/3b318ee1-78c0-45ad-af92-f807188adb2d">

The carrots 🥕 now respond correctly when their respective menus are
opened:
URL:
`http://localhost:3000/department/1?last_name=&first_name=&badge=&min_age=16&max_age=85&unique_internal_identifier=&require_photo=True&submit=Submit`
<img width="1470" alt="Screenshot 2023-07-11 at 2 21 50 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/d73b2c68-93ae-46b4-ad94-14666608fe56">

 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.
AetherUnbound pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Oct 9, 2023
lucyparsons#798

Add the ability for the user to filter officers by the availability of a
photo, format the `list_officer.html` file using
[`djlint`](https://www.djlint.com/), correct carrot behavior on officer
search, center displayed officer photos, and update relevant test case.

Images on the search page are now centered (laptop screen):
<img width="1469" alt="Screenshot 2023-07-11 at 12 18 34 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/2ee9a10d-9f3c-40ad-be19-9f43442cc9f5">

Images on the search page are now centered (phone screen):
<img width="621" alt="Screenshot 2023-07-11 at 12 18 45 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/3b318ee1-78c0-45ad-af92-f807188adb2d">

The carrots 🥕 now respond correctly when their respective menus are
opened:
URL:
`http://localhost:3000/department/1?last_name=&first_name=&badge=&min_age=16&max_age=85&unique_internal_identifier=&require_photo=True&submit=Submit`
<img width="1470" alt="Screenshot 2023-07-11 at 2 21 50 PM"
src="https://github.com/lucyparsons/OpenOversight/assets/5885605/d73b2c68-93ae-46b4-ad94-14666608fe56">

 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve /department/id search view for mobile Filter by photo availability
4 participants