123456789101112131415161718192021222324252627282930 |
- from flask import abort, 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.query.get(file_id)
- if file is None:
- return abort(404)
- # 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)
|