nopaque/app/api/jobs.py

19 lines
479 B
Python

from flask_restx import Namespace, Resource
from .auth import token_auth
from ..models import Job
ns = Namespace('jobs', description='Job operations')
@ns.route('/')
class JobList(Resource):
'''Shows a list of all jobs, and lets you POST to add new job'''
@ns.doc(security='apiKey')
@token_auth.login_required
def get(self):
'''List all jobs'''
jobs = Job.query.all()
return [job.to_dict(include_relationships=False) for job in jobs]