user_reports.py 736 B

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