Adds is_admin boolean flag to user schema

This commit is contained in:
Aaron Louie 2020-07-29 22:45:56 -04:00
parent f897ee3aea
commit 63537d7765
1 changed files with 3 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import datetime
import jwt
from marshmallow import fields
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
from crc import db, app
@ -18,6 +19,7 @@ class UserModel(db.Model):
first_name = db.Column(db.String, nullable=True)
last_name = db.Column(db.String, nullable=True)
title = db.Column(db.String, nullable=True)
# TODO: Add Department and School
def is_admin(self):
@ -64,3 +66,4 @@ class UserModelSchema(SQLAlchemyAutoSchema):
load_instance = True
include_relationships = True
is_admin = fields.Function(lambda obj: obj.is_admin())