user_reports.py 624 B

123456789101112131415161718192021222324
  1. from typing import List
  2. from django.http import HttpResponse
  3. from glitchtip.api.authentication import AuthHttpRequest
  4. from glitchtip.api.pagination import apaginate
  5. from ..models import UserReport
  6. from ..schema import UserReportSchema
  7. from . import router
  8. @router.get(
  9. "/issues/{int:issue_id}/user-reports",
  10. response=List[UserReportSchema],
  11. by_alias=True,
  12. )
  13. @apaginate
  14. async def list_user_reports(request: AuthHttpRequest, response: HttpResponse, issue_id: int):
  15. user_id = request.auth
  16. return UserReport.objects.filter(
  17. project__organization__users=user_id,
  18. issue__id=issue_id
  19. )