-
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
Officer unit view #783
Officer unit view #783
Conversation
Not sure how to add reviewers Working on a few tests that got weird, but code-complete. |
@@ -227,6 +227,35 @@ def create_officer_from_row(row, department_id): | |||
process_salary(row, officer, compare=False) | |||
|
|||
|
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 was added - there was a weird issue of failing unit tests on the first PR. I updated the test data to have datetime's for start_date + resign_date on assignments. Without this equality check, we would be == comparing datetime(2020, 01, 01) to '2020-01-01', which would fail and we would trigger spurious row updates and fail the tests.
|
||
return datetime.datetime(start_year, 1, 1, 00, 00, 00) \ | ||
+ datetime.timedelta(days=365 * (end_year - start_year) * bytes_to_float(seed)) | ||
|
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.
Added pick_date
to get an idempotent but random-enough date for officers. Jumbles it up based on name
OpenOversight/tests/conftest.py
Outdated
img_id = random.choice(images).id | ||
return models.Face(officer_id=officer.id, | ||
img_id=img_id, | ||
original_image_id=img_id) |
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.
fixing a bug - patch-pulled this in from my s3
PR
OpenOversight/app/main/forms.py
Outdated
@@ -46,6 +46,7 @@ class FindOfficerForm(Form): | |||
unique_internal_identifier = StringField('unique_internal_identifier', default='', validators=[Regexp(r'\w*'), Length(max=55)]) | |||
dept = QuerySelectField('dept', validators=[DataRequired()], | |||
query_factory=dept_choices, get_label='name') | |||
unit = SelectField('unit', default='Not Sure') |
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.
You are using a SelectField
without providing choices. This is what leads to the error with test_user_can_use_form_to_get_to_browse
(although this certainly should be surfaced better)
Since the options for unit are not static like race and gender and furthermore depend on the department that was selected, I think the right choice would be to do whatever the solution for rank
is, since that field has similar constraints (I am not familiar with how this is done though)
For the two failing tests
The problem was that the changes in the PR add some new units to the test-data, which results in the random pick selecting a unit that does not belong to the department of the area coordinator, which makes the validation fail. This points to several issues, specifically how we surface failures in validation (we don't at all) and the problems with choosing randomly from a pool where some choices make the test fail. |
alright. Fixed some of that other issue of form errors dying silently. I skipped adding the logging in a few places that had the form validation jumbled with a bunch of other conditionals. Tests passing, lint passing. Thanks a whole heap @abandoned-prototype - you definitely unstuck me. Much appreciated. |
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.
Works perfectly as advertised, great job on this! I also appreciate the addition Make targets. Just one comment I'll add is that the extra logging doesn't give much useful information. I tried hitting several form errors on the site and they mostly just logged the message INFO in views: {}
. So in the future it would probably be good to either include more context in those log messages or instead refrain from logging them.
@dismantl - that's interesting and unfortunate. The logging was at least popping up on the failed unit tests but I didn't test in-depth and didn't read enough on WTForms to figure out why |
Status
Ready for review
Description of Changes
Fixes #733 + #786
Changes proposed in this pull request:
make lint
andmake attach
with updated docs, to makefilelogging.info
Notes for Deployment
Screenshots (if appropriate)
Tests and linting
develop
flake8
checks pass