mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add switch for admins to get all jobs (of all users)
This commit is contained in:
parent
4ffb10fd11
commit
99614a56a9
@ -1,6 +1,7 @@
|
|||||||
from flask import abort, jsonify
|
from flask import abort, jsonify, request
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from . import api
|
from . import api
|
||||||
|
from ..models import Job
|
||||||
|
|
||||||
|
|
||||||
@api.route('/v1.0/corpora')
|
@api.route('/v1.0/corpora')
|
||||||
@ -31,7 +32,15 @@ def corpus(corpus_id):
|
|||||||
@login_required
|
@login_required
|
||||||
def jobs():
|
def jobs():
|
||||||
jobs = []
|
jobs = []
|
||||||
for job in current_user.jobs.all():
|
all = request.args.get('all')
|
||||||
|
if all and all.lower() == 'true':
|
||||||
|
if current_user.is_administrator():
|
||||||
|
jobs_query = Job.query
|
||||||
|
else:
|
||||||
|
return abort(403)
|
||||||
|
else:
|
||||||
|
jobs_query = current_user.jobs
|
||||||
|
for job in jobs_query.all():
|
||||||
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,
|
||||||
|
Loading…
Reference in New Issue
Block a user