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

Multiple allowed users for PermitArea (HPH-36) #276

Merged
merged 6 commits into from
Nov 24, 2023

Conversation

suutari-ai
Copy link
Collaborator

Add support for allowing sharing of the PermitAreas between operators and the enforcer.

Previously it was possible to use each PermitArea for just a single enforcer or operator.
This was especially problematic, because the PermitArea codes were unique within
enforcement domains so it was not even possible to create duplicate areas with the
same identifiers.

Add a QuerySet method named "for_user" for PermitAreas and use it
instead of direct filtering by the field name.  This allows changing the
field name without changes to these filters.

Refs HPH-36
@suutari-ai suutari-ai force-pushed the permit-area-multiple-users branch from 51116b0 to ecb07b5 Compare November 24, 2023 06:51
@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2023

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (1cefe0a) 94.70% compared to head (7531956) 94.48%.

Files Patch % Lines
...grations/0047_populate_permitarea_allowed_users.py 53.84% 5 Missing and 1 partial ⚠️
parkings/tests/api/operator/permit_area.py 0.00% 6 Missing ⚠️
parkings/importers/geojson_permit_areas.py 62.50% 1 Missing and 2 partials ⚠️
parkkihubi_hel/importers/permit_areas.py 62.50% 1 Missing and 2 partials ⚠️
parkings/api/operator/permit.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #276      +/-   ##
==========================================
- Coverage   94.70%   94.48%   -0.22%     
==========================================
  Files         187      190       +3     
  Lines        5797     5843      +46     
  Branches      389      398       +9     
==========================================
+ Hits         5490     5521      +31     
- Misses        240      250      +10     
- Partials       67       72       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@mhieta mhieta left a comment

Choose a reason for hiding this comment

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

LGTM!

Add a new many-2-many field named "allowed_users" to PermitArea and
populate it with the user object from the "permitted_user" field.

This allows multiple operators/enforcers to use the same PermitAreas for
their permits.

also make the permitted_user field nullable for now to allow migrations
to be reversed.

Refs HPH-36
Remove the "permitted_user" field from the PermitArea model and update
all code to use the "allowed_users" instead, because the field is now
redundant.

Refs HPH-36
Rename all occurences of "permitted_user" to "allowed_user" so that code
matches the new naming of the field.

The tests are still utilizing just a single allowed user per area, but
that should be fine for now.

Refs HPH-36
Make the "allowed_user" parameter optional, since now it's possible to
create the PermitAreas without any allowed users and it could make sense
to import new areas without assigning them to any users at import time.

Refs HPH-36
Add a few test cases that make sure that the creation of permits via the
Operator API works correctly even when the PermitArea has more than one
allowed user.

Refs HPH-36
@suutari-ai suutari-ai force-pushed the permit-area-multiple-users branch from ecb07b5 to 7531956 Compare November 24, 2023 09:22
Copy link

@mhieta mhieta left a comment

Choose a reason for hiding this comment

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

Good!

@suutari-ai suutari-ai merged commit d90797f into master Nov 24, 2023
5 of 7 checks passed
@suutari-ai suutari-ai deleted the permit-area-multiple-users branch November 24, 2023 09:31
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.

3 participants