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

Feature/#554 filter destruction lists #572

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

svenvandescheur
Copy link
Contributor

closes #554

@svenvandescheur svenvandescheur force-pushed the feature/#554-filter-destruction-lists branch from 50661f6 to eec7128 Compare December 20, 2024 12:51
@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 92.47312% with 7 lines in your changes missing coverage. Please review.

Project coverage is 84.30%. Comparing base (4e0eaff) to head (103afe9).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
frontend/src/pages/landing/Landing.tsx 75.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #572      +/-   ##
==========================================
+ Coverage   84.18%   84.30%   +0.12%     
==========================================
  Files         208      212       +4     
  Lines        5639     5716      +77     
  Branches      570      576       +6     
==========================================
+ Hits         4747     4819      +72     
- Misses        892      897       +5     

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

@svenvandescheur svenvandescheur force-pushed the feature/#554-filter-destruction-lists branch 12 times, most recently from f7e024e to e54e2b7 Compare December 20, 2024 14:14
@svenvandescheur svenvandescheur marked this pull request as ready for review December 20, 2024 14:24
Comment on lines +20 to +24
class UsersView(ListAPIView):
serializer_class = UserSerializer

def get_queryset(self) -> QuerySet[User]:
return User.objects.all()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason for not doing:

Suggested change
class UsersView(ListAPIView):
serializer_class = UserSerializer
def get_queryset(self) -> QuerySet[User]:
return User.objects.all()
class UsersView(ListAPIView):
serializer_class = UserSerializer
queryset = User.objects.all()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • For endpoints using the manager method that filter on permissions, this may cause issues when initializing as the queryset is initialized straight away.
  • For the this particular case its uses the get_queryset method for consistency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

These endpoints are getting a bit out of hand, maybe we should refactor to use filters?
So then we would have GET /api/v1/users?role=reviewer ?

Copy link
Contributor Author

@svenvandescheur svenvandescheur Dec 20, 2024

Choose a reason for hiding this comment

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

return self._users_with_permission(permission)

def _users_with_permission(self, permission: Permission) -> "UserQuerySet":
return self.filter( # noqa
Copy link
Collaborator

Choose a reason for hiding this comment

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

why the added noqa?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My IDE resolves the type to be QuerySet but AFAIK if executed in this context it will return a UserQuerySet.

@svenvandescheur svenvandescheur force-pushed the feature/#554-filter-destruction-lists branch from e54e2b7 to 06c06e7 Compare December 20, 2024 15:11
@svenvandescheur svenvandescheur force-pushed the feature/#554-filter-destruction-lists branch from 06c06e7 to 103afe9 Compare December 20, 2024 15:15
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.

Recordmanager moet kunnen filteren en sorteren op lijsten
3 participants