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

Do more filtering in new base views #5580

Merged
merged 1 commit into from
Oct 24, 2024
Merged

Conversation

rowanseymour
Copy link
Member

  • Make BaseListView filter by is_active=True
  • Make BaseUpdateView filter by is_active=True and is_system=False
  • Make BaseDeleteView noop for is_system=True

@@ -1112,7 +1112,7 @@ def build_context_menu(self, menu):
)

def derive_queryset(self, **kwargs):
return super().derive_queryset(**kwargs).filter(is_active=True, is_system=False)
return super().derive_queryset(**kwargs).filter(is_proxy=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

is_proxy for fields means "created_on" etc which are proxies for Contact model attributes

@@ -684,8 +684,7 @@ def get_context_data(self, **kwargs):
return context

def derive_queryset(self, *args, **kwargs):
qs = super().derive_queryset(*args, **kwargs)
return qs.exclude(is_system=True).exclude(is_active=False)
return super().derive_queryset(*args, **kwargs).exclude(is_system=True)
Copy link
Member Author

Choose a reason for hiding this comment

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

is_system for flows means single message campaign flows for now... these might become broadcasts anyways


if not self.request.user.is_authenticated:
return qs.none() # pragma: no cover
Copy link
Member Author

Choose a reason for hiding this comment

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

this can't happen.. base list views use OrgPermsMixin so you can't be here if org isn't set

@rowanseymour rowanseymour force-pushed the base_list_view_filtering branch 2 times, most recently from 4bec02f to 8388fee Compare October 24, 2024 19:22
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2852006) to head (820c009).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5580   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          550       550           
  Lines        25671     25674    +3     
=========================================
+ Hits         25671     25674    +3     

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

@rowanseymour rowanseymour merged commit edbace2 into main Oct 24, 2024
5 checks passed
@rowanseymour rowanseymour deleted the base_list_view_filtering branch October 24, 2024 22:08
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants