Skip to content
Snippets Groups Projects
Commit 99614a56 authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Add switch for admins to get all jobs (of all users)

parent 4ffb10fd
No related branches found
No related tags found
No related merge requests found
from flask import abort, jsonify
from flask import abort, jsonify, request
from flask_login import current_user, login_required
from . import api
from ..models import Job
@api.route('/v1.0/corpora')
......@@ -31,7 +32,15 @@ def corpus(corpus_id):
@login_required
def 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,
'creation_date': job.creation_date.timestamp(),
'description': job.description,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment