|
|
@ -64,7 +64,7 @@ class User(db.Model): |
|
|
|
created_at = db.Column(db.DateTime, nullable=False) |
|
|
|
created_at = db.Column(db.DateTime, nullable=False) |
|
|
|
groups = db.relationship('Group', |
|
|
|
groups = db.relationship('Group', |
|
|
|
secondary=user_groups, |
|
|
|
secondary=user_groups, |
|
|
|
backref=db.backref('users', lazy='dynamic')) |
|
|
|
backref=db.backref('users', lazy='select')) |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, username, fullname, passhash, token=None, |
|
|
|
def __init__(self, username, fullname, passhash, token=None, |
|
|
|
issued_date=None, verified=False): |
|
|
|
issued_date=None, verified=False): |
|
|
@ -92,6 +92,11 @@ class User(db.Model): |
|
|
|
'issued_date': datetime.date.today().isoformat()}) |
|
|
|
'issued_date': datetime.date.today().isoformat()}) |
|
|
|
return hmac.new(self.created_at.isoformat(), phrase).hexdigest() |
|
|
|
return hmac.new(self.created_at.isoformat(), phrase).hexdigest() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __repr__(self): |
|
|
|
|
|
|
|
return 'User {username}-{fullname}'.format( |
|
|
|
|
|
|
|
username=self.username, |
|
|
|
|
|
|
|
fullname=self.fullname) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Group(db.Model): |
|
|
|
class Group(db.Model): |
|
|
|
id = db.Column(db.Integer, primary_key=True) |
|
|
|
id = db.Column(db.Integer, primary_key=True) |
|
|
@ -99,8 +104,7 @@ class Group(db.Model): |
|
|
|
owner = db.Column(db.String, db.ForeignKey('user.username')) |
|
|
|
owner = db.Column(db.String, db.ForeignKey('user.username')) |
|
|
|
places = db.relationship('Place', |
|
|
|
places = db.relationship('Place', |
|
|
|
secondary=group_places, |
|
|
|
secondary=group_places, |
|
|
|
backref='groups', |
|
|
|
backref=db.backref('groups', lazy='select')) |
|
|
|
lazy='dynamic') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, name, owner): |
|
|
|
def __init__(self, name, owner): |
|
|
|
self.name = name |
|
|
|
self.name = name |
|
|
|