diff options
author | Sam | 2013-10-30 14:52:09 -0500 |
---|---|---|
committer | Sam | 2013-10-30 14:52:09 -0500 |
commit | 78ff756b0d4416f8b1fc4c0008d39bd14b5194f3 (patch) | |
tree | b2b3624414e0f39bb602245fe217b78a30601414 /wqflask/wqflask/model.py | |
parent | 5c5671f3c3353f6adc1ce5d9cab8f9f4de5a4e05 (diff) | |
download | genenetwork2-78ff756b0d4416f8b1fc4c0008d39bd14b5194f3.tar.gz |
Progress on user collections
Diffstat (limited to 'wqflask/wqflask/model.py')
-rw-r--r-- | wqflask/wqflask/model.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py index c89dc80a..c1ad0a78 100644 --- a/wqflask/wqflask/model.py +++ b/wqflask/wqflask/model.py @@ -50,6 +50,10 @@ class User(Base): lazy='dynamic' # Necessary for filter in login_count ) + user_collections = relationship("UserCollection", + order_by="asc(UserCollection.name)", + ) + @property def login_count(self): return self.logins.filter_by(successful=True).count() @@ -98,3 +102,6 @@ class UserCollection(Base): created_timestamp = Column(DateTime(), default=lambda: datetime.datetime.utcnow()) changed_timestamp = Column(DateTime(), default=lambda: datetime.datetime.utcnow()) members = Column(Text) # We're going to store them as a json list + + # This index ensures a user doesn't have more than one collection with the same name + __table_args__ = (Index('usercollection_index', "user", "name"), ) |