project.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from django.views.decorators.http import require_POST
  2. from pycs_api.views.base import JsonResponseView
  3. from rest_framework.decorators import permission_classes
  4. class ProjectView(JsonResponseView):
  5. """
  6. serves POST and GET for '/projects/'
  7. staticmethods serve POST methods for
  8. '/projects/<id>/name'
  9. '/projects/<id>/description'
  10. '/projects/<id>/remove'
  11. """
  12. http_method_names = ["get", "post"]
  13. def get(self, request, *args, **kwargs):
  14. """ lists projects """
  15. return self.respond([
  16. dict(name="Project 1", description="Desc1", ),
  17. dict(name="Project 2", description="Desc2"),
  18. ])
  19. def post(self, request, *args, **kwargs):
  20. """ creates a project """
  21. return self.respond()
  22. @require_POST
  23. @classmethod
  24. def remove(cls, request, project_id: int):
  25. """ removes a project """
  26. return cls.respond()
  27. @require_POST
  28. @classmethod
  29. def edit_name(cls, request, project_id: int):
  30. """ edit project's name """
  31. return cls.respond()
  32. @require_POST
  33. @classmethod
  34. def edit_description(cls, request, project_id: int):
  35. """ edit project's description """
  36. return cls.respond()
  37. @require_POST
  38. @classmethod
  39. def run_external_storage(cls, request, project_id: int):
  40. """ runs external storage routine """
  41. return cls.respond()
  42. @require_POST
  43. @classmethod
  44. def run_label_provider(cls, request, project_id: int):
  45. """ runs label provider routine """
  46. return cls.respond()