diff options
author | emkael <emkael@tlen.pl> | 2016-10-25 16:08:14 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-10-25 18:55:16 +0200 |
commit | 95e5a74b0663e9110ea638dd5d809e9fd1541fa9 (patch) | |
tree | 7407564370f21e4f6923e2ad615fa01e52ff7b92 /app/backend/rcal | |
parent | 6edff35cd3315df12c0b41986eadbf29de8a67b2 (diff) |
* model for user auth cookies
Diffstat (limited to 'app/backend/rcal')
-rw-r--r-- | app/backend/rcal/model.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/backend/rcal/model.py b/app/backend/rcal/model.py index 50f9f94..4715657 100644 --- a/app/backend/rcal/model.py +++ b/app/backend/rcal/model.py @@ -5,6 +5,8 @@ from sqlalchemy.orm import relationship from sqlalchemy.types import (TIMESTAMP, Boolean, DateTime, Integer, String, TypeDecorator) +from sqlalchemy_utils import types + from dateutil.tz import tzutc @@ -149,7 +151,34 @@ class User(BASE): grouped_view = Column(Boolean) last_login = Column(UTCDateTime) + auth_keys = relationship( + 'UserAuthKey', + back_populates='user', + cascade="all", + passive_deletes=True, + order_by='UserAuthKey.id') + calendars = relationship('Calendar', secondary=user_selections) + +class UserAuthKey(BASE): + __tablename__ = 'user_auth_keys' + + id = Column(Integer, primary_key=True) + auth_key = Column(String(255), unique=True, index=True) + ip_address = Column(types.IPAddressType) + + _user = Column( + Integer, + ForeignKey( + 'users.id', + onupdate='CASCADE', + ondelete='CASCADE')) + user = relationship( + 'User', + back_populates='auth_keys', + order_by='UserAuthKey.id') + + __all__ = ('Calendar', 'Entry', 'Category', 'User') |