2019-08-28 03:46:04 +02:00
|
|
|
from models import db
|
|
|
|
|
|
|
|
|
|
|
|
class User(db.Model):
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
username = db.Column(db.String(80), unique=True, nullable=False)
|
|
|
|
admin = db.Column(db.Boolean)
|
|
|
|
bias = db.Column(db.Integer)
|
|
|
|
runs = db.relation('Order',
|
|
|
|
backref='courrier',
|
|
|
|
primaryjoin='Order.courrier_id==User.id',
|
|
|
|
foreign_keys='Order.courrier_id')
|
|
|
|
orderItems = db.relationship('OrderItem', backref='user', lazy='dynamic')
|
|
|
|
|
|
|
|
def configure(self, username, admin, bias):
|
|
|
|
self.username = username
|
|
|
|
self.admin = admin
|
|
|
|
self.bias = bias
|
|
|
|
|
|
|
|
def is_authenticated(self):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def is_active(self):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def is_admin(self):
|
|
|
|
return self.admin
|
|
|
|
|
|
|
|
def is_anonymous(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def get_id(self):
|
2019-08-31 00:50:01 +02:00
|
|
|
return str(self.id)
|
2019-08-28 03:46:04 +02:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return '%s' % self.username
|