| 24 | |
| 25 | |
| 26 | class User(db.Model): |
| 27 | |
| 28 | __tablename__ = "users" |
| 29 | |
| 30 | id = db.Column(db.Integer, primary_key=True) |
| 31 | name = db.Column(db.String, nullable=False) |
| 32 | email = db.Column(db.String, nullable=False) |
| 33 | password = db.Column(db.String) |
| 34 | posts = relationship("BlogPost", backref="author") |
| 35 | |
| 36 | def __init__(self, name, email, password): |
| 37 | self.name = name |
| 38 | self.email = email |
| 39 | self.password = bcrypt.generate_password_hash(password) |
| 40 | |
| 41 | def is_authenticated(self): |
| 42 | return True |
| 43 | |
| 44 | def is_active(self): |
| 45 | return True |
| 46 | |
| 47 | def is_anonymous(self): |
| 48 | return False |
| 49 | |
| 50 | def get_id(self): |
| 51 | return unicode(self.id) |
| 52 | |
| 53 | def __repr__(self): |
| 54 | return '<name - {}>'.format(self.name) |
no outgoing calls
no test coverage detected