6
0

GetProjectResults.py 725 B

1234567891011121314151617181920212223242526
  1. from flask import jsonify
  2. from flask.views import View
  3. from pycs.database.Project import Project
  4. from pycs.interfaces.MediaStorage import MediaStorage
  5. class GetProjectResults(View):
  6. """
  7. get a list of all files and annotations for a project
  8. """
  9. # pylint: disable=arguments-differ
  10. methods = ['GET']
  11. def dispatch_request(self, user: str, project_id: int):
  12. # pylint: disable=unused-argument
  13. # get project from database
  14. project = Project.get_or_404(project_id)
  15. # map media files to a dict
  16. storage = MediaStorage(project.id, None)
  17. files = list(map(lambda f: f.serialize(), storage.files().iter()))
  18. # return result
  19. return jsonify(files)