Skip to content
Snippets Groups Projects
Commit e934a15e authored by Joseph Weston's avatar Joseph Weston
Browse files

add 'Students' resource for getting student list

parent 7fad559a
Branches
Tags
No related merge requests found
......@@ -4,6 +4,7 @@ from flask_restful import Api
from .resources.graders import Graders
from .resources.exams import Exams, ExamConfig
from .resources.pdfs import Pdfs
from .resources.students import Students
api_bp = Blueprint(__name__, __name__)
......@@ -20,3 +21,4 @@ api.add_resource(Graders, '/graders')
api.add_resource(Exams, '/exams')
api.add_resource(ExamConfig, '/exams/<int:exam_id>')
api.add_resource(Pdfs, '/pdfs/<int:exam_id>')
api.add_resource(Students, '/students')
from flask_restful import Resource
from pony import orm
from ..models import Student
class Students(Resource):
"""Getting a list of students."""
@orm.db_session
def get(self):
"""get all students for the course.
Returns
-------
list of:
id: int
first_name: str
last_name: str
email: str
"""
return [
{
'id': s.id,
'first_name': s.first_name,
'last_name': s.last_name,
'email': s.email,
}
for s in Student.select()
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment