From f75283b1a20969fcb359644ef3ddc62edee8c99c Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 9 Sep 2018 14:10:42 -0700 Subject: [PATCH] ship 1.0 --- photoapp/types.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/photoapp/types.py b/photoapp/types.py index 3f56c9f..a0fada4 100644 --- a/photoapp/types.py +++ b/photoapp/types.py @@ -1,7 +1,6 @@ from sqlalchemy import Column, Integer, String, DateTime, Unicode, DECIMAL, ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declarative_base - import uuid @@ -19,6 +18,9 @@ class PhotoSet(Base): files = relationship("Photo", back_populates="set") + title = Column(String) + description = Column(String) + class Photo(Base): __tablename__ = 'files' @@ -36,3 +38,29 @@ class Photo(Base): hash = Column(String(length=64), unique=True) path = Column(Unicode) format = Column(String(length=64)) # TODO how long can a mime string be + + +class Tag(Base): + __tablename__ = 'tags' + + id = Column(Integer, primary_key=True) + uuid = Column(Unicode, default=lambda: str(uuid.uuid4())) + created = Column(DateTime) + modified = Column(DateTime) + title = Column(String) + slug = Column(String) + description = Column(String) + + entries = relationship("TagItem", back_populates="tag") + + +class TagItem(Base): + __tablename__ = 'tag_items' + + id = Column(Integer, primary_key=True) + tag_id = Column(Integer, ForeignKey("tags.id")) + + tag = relationship("Tag", back_populates="entries", foreign_keys=[tag_id]) + + item_uuid = Column(String, unique=True) + order = Column(Integer, default=0)