6
0

ListProjectCollections.py 659 B

12345678910111213141516171819202122232425
  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, user: str, project_id: int):
  12. # pylint: disable=unused-argument
  13. # find project
  14. project = Project.get_or_404(project_id)
  15. # get collection list
  16. collections = Collection.update_autoselect(project.collections)
  17. # return files
  18. return jsonify(collections.all())