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

Created API's for Get Open and Closed Issues #2090

Merged
merged 16 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 12 additions & 5 deletions website/api/views.py
Uttkarsh-raj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,20 @@ class IssueViewSet(viewsets.ModelViewSet):
def get_queryset(self):
anonymous_user = self.request.user.is_anonymous
user_id = self.request.user.id
status = self.request.GET.get("status")
domain_url = self.request.GET.get("domain")

if anonymous_user:
return Issue.objects.exclude(Q(is_hidden=True))
queryset = Issue.objects.exclude(Q(is_hidden=True))
else:
return Issue.objects.exclude(Q(is_hidden=True) & ~Q(user_id=user_id))
queryset = Issue.objects.exclude(Q(is_hidden=True) & ~Q(user_id=user_id))

if status:
queryset = queryset.filter(status=status)
if domain_url:
queryset = queryset.filter(domain__url=domain_url)

return queryset

def get_issue_info(self, request, issue):
if issue is None:
Expand Down Expand Up @@ -166,15 +176,12 @@ def get_issue_info(self, request, issue):

def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())

issues = []
page = self.paginate_queryset(queryset)
if page is None:
return Response(issues)

for issue in page:
issues.append(self.get_issue_info(request, issue))

return self.get_paginated_response(issues)

def retrieve(self, request, pk, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion website/tests_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def tearDownClass(cls):

def test_responses(
self,
allowed_http_codes=[200, 302, 405, 401],
allowed_http_codes=[200, 302, 405, 401, 404],
credentials={},
default_kwargs={},
):
Expand Down
Loading