views.py 815 B

12345678910111213141516171819202122232425
  1. from rest_framework import views
  2. from rest_framework.response import Response
  3. from .importer import GlitchTipImporter
  4. from .serializers import ImportSerializer
  5. class ImportAPIView(views.APIView):
  6. """Import members, projects, and teams for an organization of which you are an Admin of"""
  7. serializer_class = ImportSerializer
  8. def post(self, request):
  9. serializer = self.serializer_class(
  10. data=request.data, context={"request": request}
  11. )
  12. serializer.is_valid(raise_exception=True)
  13. data = serializer.validated_data
  14. importer = GlitchTipImporter(
  15. data["url"], data["authToken"], data["organizationSlug"].slug
  16. )
  17. importer.check_auth()
  18. importer.run(organization_id=data["organizationSlug"].pk)
  19. return Response()