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

[#1078] Hide rejected data in the approved list #1128

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Changes from all commits
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
30 changes: 24 additions & 6 deletions backend/api/v1/v1_data/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,21 +775,39 @@ def list_pending_batch(request, version):
status=DataApprovalStatus.rejected
)
if approved:
queryset = queryset.filter(status=DataApprovalStatus.approved)
queryset = queryset.filter(
status=DataApprovalStatus.approved,
)
queryset = queryset.exclude(
batch_id__in=rejected.values_list('batch_id', flat=True)
)
else:
rejected_by_current_user = ViewPendingDataApproval.objects.filter(
status=DataApprovalStatus.rejected,
user=user
)
if subordinate:
queryset = queryset.filter(
level_id__lt=F('pending_level'),
batch__approved=False)
queryset = queryset.union(
rejected_by_current_user.values_list('batch_id', flat=True)
)
else:
queryset = queryset.filter(
level_id=F('pending_level'),
batch__approved=False)
if rejected:
# extend query set with rejected batch
queryset = queryset.union(
rejected.values_list('batch_id', flat=True)
)
queryset = queryset.exclude(
batch_id__in=rejected_by_current_user.values_list(
'batch_id', flat=True)
)
rejected = rejected.exclude(
batch_id__in=rejected_by_current_user.values_list(
'batch_id', flat=True)
)
queryset = queryset.union(
rejected.values_list('batch_id', flat=True)
)
queryset = queryset.values_list('batch_id', flat=True).order_by('-id')

paginator = PageNumberPagination()
Expand Down