diff options
author | Boris Bobrov <breton@cynicmansion.ru> | 2018-07-10 18:29:30 +0200 |
---|---|---|
committer | Boris Bobrov <breton@cynicmansion.ru> | 2018-07-10 18:29:30 +0200 |
commit | e08de70757b6f973bc2955f1b3292d383a19b21d (patch) | |
tree | f60ad20e55538e1945cbc61284b09540dd601975 /mediagoblin/db/models.py | |
parent | 588162b861f4993ee8412b14601b215505134bfc (diff) | |
parent | 7ab18019782b285a5bf9fc79227e0d0d4896398a (diff) | |
download | mediagoblin-e08de70757b6f973bc2955f1b3292d383a19b21d.tar.lz mediagoblin-e08de70757b6f973bc2955f1b3292d383a19b21d.tar.xz mediagoblin-e08de70757b6f973bc2955f1b3292d383a19b21d.zip |
Merge remote-tracking branch 'gsoc2016/Subtitle-1'
Diffstat (limited to 'mediagoblin/db/models.py')
-rw-r--r-- | mediagoblin/db/models.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 3b85b07a..c19fe4da 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -574,6 +574,15 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin): name=v["name"], filepath=v["filepath"]) ) + subtitle_files_helper = relationship("MediaSubtitleFile", + cascade="all, delete-orphan", + order_by="MediaSubtitleFile.created" + ) + subtitle_files = association_proxy("subtitle_files_helper", "dict_view", + creator=lambda v: MediaSubtitleFile( + name=v["name"], filepath=v["filepath"]) + ) + tags_helper = relationship("MediaTag", cascade="all, delete-orphan" # should be automatically deleted ) @@ -907,6 +916,22 @@ class MediaAttachmentFile(Base): """A dict like view on this object""" return DictReadAttrProxy(self) +class MediaSubtitleFile(Base): + __tablename__ = "core__subtitle_files" + + id = Column(Integer, primary_key=True) + media_entry = Column( + Integer, ForeignKey(MediaEntry.id), + nullable=False) + name = Column(Unicode, nullable=False) + filepath = Column(PathTupleWithSlashes) + created = Column(DateTime, nullable=False, default=datetime.datetime.utcnow) + + @property + def dict_view(self): + """A dict like view on this object""" + return DictReadAttrProxy(self) + class Tag(Base): __tablename__ = "core__tags" @@ -1618,7 +1643,7 @@ class Graveyard(Base): return context MODELS = [ LocalUser, RemoteUser, User, MediaEntry, Tag, MediaTag, Comment, TextComment, - Collection, CollectionItem, MediaFile, FileKeynames, MediaAttachmentFile, + Collection, CollectionItem, MediaFile, FileKeynames, MediaAttachmentFile, MediaSubtitleFile, ProcessingMetaData, Notification, Client, CommentSubscription, Report, UserBan, Privilege, PrivilegeUserAssociation, RequestToken, AccessToken, NonceTimestamp, Activity, Generator, Location, GenericModelReference, Graveyard] |