12345678910111213141516171819202122232425262728 |
- from flask import jsonify
- from flask.views import View
- from pycs.database.File import File
- class GetPreviousAndNextFile(View):
- """
- return the previous and the next file
- """
- # pylint: disable=arguments-differ
- methods = ['GET']
- def dispatch_request(self, file_id: int):
- # get file from database
- file = File.get_or_404(file_id)
- # get previous and next
- result = {
- 'previous': file.previous(),
- 'next': file.next(),
- 'previousInCollection': file.previous_in_collection(),
- 'nextInCollection': file.next_in_collection()
- }
- # return data
- return jsonify(result)
|