endorsement/models.py
2018-07-12 19:45:52 +02:00

20 lines
749 B
Python

from app import db
class User(db.Model):
__tablename__ = "Users"
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
achievements = db.relationship("Achievement", backref="person", lazy=True)
endorses = db.relationship("Achievement", backref="endorsed_by", lazy=True)
def __repr__(self):
return '<User %r>' % self.username
class Achievement(db.Model):
__tablename__ = "Achievement"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128), nullable=False)
person_id = db.Column(db.Integer, db.ForeignKey("Users.id"))
def __repr__(self):
return '<Achievement %r from %r>' % (self.name, self.person.username)