ListProjectCollections.py 606 B

123456789101112131415161718192021222324
  1. from flask import jsonify
  2. from flask.views import View
  3. from pycs.database.Collection import Collection
  4. from pycs.database.Project import Project
  5. class ListProjectCollections(View):
  6. """
  7. return a list of collections for a given project
  8. """
  9. # pylint: disable=arguments-differ
  10. methods = ['GET']
  11. def dispatch_request(self, project_id: int):
  12. # find project
  13. project = Project.get_or_404(project_id)
  14. # get collection list
  15. collections = Collection.update_autoselect(project.collections)
  16. # return files
  17. return jsonify(collections.all())