|
@ -83,6 +83,7 @@ class User(UserMixin, db.Model): |
|
|
member_since = db.Column(db.DateTime(), default=datetime.utcnow) |
|
|
member_since = db.Column(db.DateTime(), default=datetime.utcnow) |
|
|
last_seen = db.Column(db.DateTime(), default=datetime.utcnow) |
|
|
last_seen = db.Column(db.DateTime(), default=datetime.utcnow) |
|
|
avatar_hash = db.Column(db.String(32)) |
|
|
avatar_hash = db.Column(db.String(32)) |
|
|
|
|
|
posts = db.relationship('Post', backref='author', lazy='dynamic') |
|
|
|
|
|
|
|
|
def __init__(self, **kwargs): |
|
|
def __init__(self, **kwargs): |
|
|
super(User, self).__init__(**kwargs) |
|
|
super(User, self).__init__(**kwargs) |
|
@ -186,6 +187,14 @@ class User(UserMixin, db.Model): |
|
|
return '<User %r>' % self.username |
|
|
return '<User %r>' % self.username |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Post(db.Model): |
|
|
|
|
|
__tablename__ = 'posts' |
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True) |
|
|
|
|
|
body = db.Column(db.Text) |
|
|
|
|
|
timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow) |
|
|
|
|
|
author_id = db.Column(db.Integer, db.ForeignKey('users.id')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AnonymousUser(AnonymousUserMixin): |
|
|
class AnonymousUser(AnonymousUserMixin): |
|
|
def can(self, perm): |
|
|
def can(self, perm): |
|
|
return False |
|
|
return False |
|
|