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

userdashboard: use new target_creator to improve filtering #2445

Merged
merged 3 commits into from
May 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions apps/userdashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,20 @@ def actions(self):
obj_content_type=ContentType.objects.get_for_model(Comment),
verb="add",
)
.filter(target_creator=user)
.exclude(
target_content_type__in=[
ContentType.objects.get_for_model(Poll),
ContentType.objects.get_for_model(Chapter),
ContentType.objects.get_for_model(Paragraph),
]
)
.exclude(
actor=user,
)
.exclude(actor=user)
.select_related("actor", "project")
.prefetch_related("obj", "target__creator")
)
filtered_comment_actions = [
action
for action in comment_actions
if not action.obj.is_blocked and action.target.creator == user
action for action in comment_actions if not action.obj.is_blocked
]
feedback_actions = (
Action.objects.filter(
Expand Down Expand Up @@ -135,6 +132,7 @@ def actions(self):
Action.objects.filter(
obj_content_type=ContentType.objects.get_for_model(Comment), verb="add"
)
.filter(target_creator=user)
.exclude(
target_content_type__in=[
ContentType.objects.get_for_model(Poll),
Expand All @@ -150,9 +148,7 @@ def actions(self):
)

filtered_comment_actions = [
action
for action in comment_actions
if not action.obj.is_blocked and action.target.creator == user
action for action in comment_actions if not action.obj.is_blocked
]
feedback_actions = (
Action.objects.filter(
Expand Down