-
Notifications
You must be signed in to change notification settings - Fork 79
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
Conversation
@media all and (min-width: 768px) and (max-width: 991px) { | ||
.filter-sidebar > .form > .btn.btn-primary:first-of-type { | ||
margin-bottom: 5px; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
min-width: 200px; | ||
min-height: 200px; | ||
height: 300px; |
There was a problem hiding this comment.
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.
officer_query = ( | ||
return ( | ||
officer_query.outerjoin(Face) | ||
.order_by(Face.officer_id.asc()) | ||
.order_by(Officer.id.desc()) | ||
) | ||
return officer_query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unnecessary variable assignment.
# Filter officers by presence of a photo | ||
if form_data["require_photo"]: | ||
officers = officers.join(Face) | ||
else: | ||
officers = officers.options(selectinload(Officer.face)) |
There was a problem hiding this comment.
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.
I linted the HTML file so that it's easier to merge in the formatting PR next. |
There was a problem hiding this 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 😄 🎉
I haven't built the project and ran it with this diff but the code itself looks good to me. |
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 |
There was a problem hiding this comment.
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.
Thank you for working on this @michplunkett! Looks terrific. |
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.
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.
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.
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.
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 usingdjlint
, 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):
Images on the search page are now centered (phone screen):
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
Tests and linting
develop
branch.pytest
passes on my local development environment.pre-commit
passes on my local development environment.