summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-02-25 15:53:36 +0100
committeremkael <emkael@tlen.pl>2016-02-25 15:53:36 +0100
commit16b4dda0f1d2df3a280b6507e12fe381ba0e8e74 (patch)
tree32f6d16f04c7152785b6c395f5b65f1212dfb0d9 /app
parent8f17fd751ed048993cb731f78ac6f949b2a77e93 (diff)
* added user accounts with calendar preferences
Diffstat (limited to 'app')
-rw-r--r--app/python/rcal/model.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/app/python/rcal/model.py b/app/python/rcal/model.py
index 94e426f..705fba2 100644
--- a/app/python/rcal/model.py
+++ b/app/python/rcal/model.py
@@ -1,5 +1,5 @@
# pylint: disable=too-few-public-methods, invalid-name
-from sqlalchemy import Column, ForeignKey
+from sqlalchemy import Column, ForeignKey, Table
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy.types import (TIMESTAMP, Boolean, DateTime, Integer, String,
@@ -8,6 +8,7 @@ from sqlalchemy.types import (TIMESTAMP, Boolean, DateTime, Integer, String,
from dateutil.tz import tzutc
+# pylint: disable=abstract-method, unused-argument
class UTCDateTime(TypeDecorator):
impl = DateTime
@@ -119,4 +120,26 @@ class Category(BASE):
session.add(category)
return category
-__all__ = ('Calendar', 'Entry', 'Category')
+
+user_selections = Table(
+ 'user_selections', BASE.metadata,
+ Column('_user', Integer,
+ ForeignKey('users.id', onupdate='CASCADE', ondelete='CASCADE')),
+ Column('_calendar', String(255),
+ ForeignKey('calendars.uid', onupdate='CASCADE', ondelete='CASCADE'))
+)
+
+
+class User(BASE):
+ __tablename__ = 'users'
+
+ id = Column(Integer, primary_key=True)
+ login = Column(String(255), unique=True, index=True)
+ password = Column(String(255))
+ is_admin = Column(Boolean)
+ last_login = Column(UTCDateTime)
+
+ calendars = relationship('Calendar',
+ secondary=user_selections)
+
+__all__ = ('Calendar', 'Entry', 'Category', 'User')