mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Return 404 if requested ressource does not exist.
This commit is contained in:
parent
22f47e3213
commit
4ffb10fd11
@ -1,4 +1,4 @@
|
|||||||
from flask import jsonify
|
from flask import abort, jsonify
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from . import api
|
from . import api
|
||||||
|
|
||||||
@ -20,8 +20,7 @@ def corpora():
|
|||||||
def corpus(corpus_id):
|
def corpus(corpus_id):
|
||||||
corpus = current_user.corpora.filter_by(id=corpus_id).first()
|
corpus = current_user.corpora.filter_by(id=corpus_id).first()
|
||||||
if not corpus:
|
if not corpus:
|
||||||
''' This should return 404 '''
|
return abort(404)
|
||||||
return jsonify(None)
|
|
||||||
return jsonify({'id': corpus.id,
|
return jsonify({'id': corpus.id,
|
||||||
'creation_date': corpus.creation_date,
|
'creation_date': corpus.creation_date,
|
||||||
'description': corpus.description,
|
'description': corpus.description,
|
||||||
@ -36,7 +35,8 @@ def jobs():
|
|||||||
jobs.append({'id': job.id,
|
jobs.append({'id': job.id,
|
||||||
'creation_date': job.creation_date.timestamp(),
|
'creation_date': job.creation_date.timestamp(),
|
||||||
'description': job.description,
|
'description': job.description,
|
||||||
'end_date': job.end_date.timestamp() if job.end_date else None,
|
'end_date': (job.end_date.timestamp() if job.end_date else
|
||||||
|
None),
|
||||||
'mem_mb': job.mem_mb,
|
'mem_mb': job.mem_mb,
|
||||||
'n_cores': job.n_cores,
|
'n_cores': job.n_cores,
|
||||||
'service': job.service,
|
'service': job.service,
|
||||||
@ -52,12 +52,12 @@ def jobs():
|
|||||||
def job(job_id):
|
def job(job_id):
|
||||||
job = current_user.jobs.filter_by(id=job_id).first()
|
job = current_user.jobs.filter_by(id=job_id).first()
|
||||||
if not job:
|
if not job:
|
||||||
''' This should return 404 '''
|
return abort(404)
|
||||||
return jsonify(None)
|
|
||||||
return jsonify({'id': job.id,
|
return jsonify({'id': job.id,
|
||||||
'creation_date': job.creation_date.timestamp(),
|
'creation_date': job.creation_date.timestamp(),
|
||||||
'description': job.description,
|
'description': job.description,
|
||||||
'end_date': job.end_date.timestamp() if job.end_date else None,
|
'end_date': (job.end_date.timestamp() if job.end_date else
|
||||||
|
None),
|
||||||
'mem_mb': job.mem_mb,
|
'mem_mb': job.mem_mb,
|
||||||
'n_cores': job.n_cores,
|
'n_cores': job.n_cores,
|
||||||
'service': job.service,
|
'service': job.service,
|
||||||
|
Loading…
Reference in New Issue
Block a user