-
Notifications
You must be signed in to change notification settings - Fork 6
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
[#929] Refactor contacts #348
Conversation
vaszig
commented
Nov 24, 2022
•
edited
Loading
edited
- Removes Contact model
- Adds user_contacts and contacts_for_approval (field for invitations) to the User model
- Removes phonenumber from contact creation and the ability to modify a contact
src/open_inwoner/accounts/migrations/0048_auto_20221124_1515.py
Outdated
Show resolved
Hide resolved
Nice refactor! Went over it early to ensure we're on the same page, think this is going in the right direction 👍 |
194c656
to
42c61ff
Compare
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.
Nice work! Big PR but this was imho as discussed, only a few minor comments
src/open_inwoner/plans/managers.py
Outdated
return self.filter( | ||
Q(contacts__contact_user=user) | Q(contacts__created_by=user) | ||
).distinct() | ||
return self.filter(Q(created_by=user) | Q(plan_contacts__id=user.id)).distinct() |
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.
Maybe it makes sense to auto-add the creating user also to plan_contacts?
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.
Agree with Alex, it will simplify code in several places
I have processed @alextreme 's reccomendations and I will push the changes as soon as the other guys have reviewed as well (I don't want to push new commits in case they have started their reviews). @alextreme can I have a bit of explanation for the third comment?About adding the creating user to the plan_contacts |
Well, if we want to simplify the Plans further we could make it so that the User creating the Plan is both registered in created_by and in the plan_contacts M2M. This way you no longer would need to check both the created_by FK and the plan_contacts M2M, you would only have to check plan_contacts. Up to you, Bart and Anna to determine if this makes sense, but as we're refactoring the Plans significantly it would make sense to also do this if you three agree with me. Otherwise you can leave it as-is. |
@vaszig I haven't started on this today so I don't mind new commits. |
Codecov Report
@@ Coverage Diff @@
## develop #348 +/- ##
===========================================
+ Coverage 96.38% 96.45% +0.06%
===========================================
Files 442 451 +9
Lines 13917 13906 -11
===========================================
- Hits 13414 13413 -1
+ Misses 503 493 -10
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
I've added some code style feedback.
But the most important thing I'm missing is a test for the significant data migration.
Here you can find a base class TestMigrations
and some usage examples for a migration test: https://github.com/open-formulieren/open-forms/search?q=TestMigrations
Also I ran the migrations on my local database and I get some styling issues (but note the names were messy test data so the gaps might not mean anything)
|
098274b
to
8afd4f0
Compare
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.
Good job!
It's much neater and more readable when before! The simplified querysets have brought a joy to my heart :)
src/open_inwoner/plans/managers.py
Outdated
return self.filter( | ||
Q(contacts__contact_user=user) | Q(contacts__created_by=user) | ||
).distinct() | ||
return self.filter(Q(created_by=user) | Q(plan_contacts__id=user.id)).distinct() |
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.
Agree with Alex, it will simplify code in several places
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.
Noticed this was waiting for me.
Comments have been resolved and this makes our life easier