From a08f0bfc86f7a6253f0e2fa1262eff0b949057b4 Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Sat, 17 Jun 2017 02:03:20 -0400 Subject: [PATCH] Re #5308 added cascade to blog mediatype --- mediagoblin/media_types/blog/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mediagoblin/media_types/blog/models.py b/mediagoblin/media_types/blog/models.py index 0e1ddf97..83f520c7 100644 --- a/mediagoblin/media_types/blog/models.py +++ b/mediagoblin/media_types/blog/models.py @@ -34,6 +34,7 @@ class BlogMixin(GenerateSlugMixin): def check_slug_used(self, slug): return check_blog_slug_used(self.author, slug, self.id) +BLOG_BACKREF_NAME = "mediatype__blogs" class Blog(Base, BlogMixin): __tablename__ = "mediatype__blogs" @@ -43,6 +44,7 @@ class Blog(Base, BlogMixin): author = Column(Integer, ForeignKey(User.id), nullable=False, index=True) #similar to uploader created = Column(DateTime, nullable=False, default=datetime.datetime.now, index=True) slug = Column(Unicode) + get_author = relationship("User", backref=backref(BLOG_BACKREF_NAME, cascade="all, delete-orphan")) @property def slug_or_id(self): @@ -66,7 +68,7 @@ class Blog(Base, BlogMixin): -BACKREF_NAME = "blogpost__media_data" +BLOG_POST_BACKREF_NAME = "blogpost__media_data" class BlogPostData(Base): __tablename__ = "blogpost__mediadata" @@ -75,7 +77,7 @@ class BlogPostData(Base): media_entry = Column(Integer, ForeignKey('core__media_entries.id'), primary_key=True) blog = Column(Integer, ForeignKey('mediatype__blogs.id'), nullable=False) get_media_entry = relationship("MediaEntry", - backref=backref(BACKREF_NAME, uselist=False, + backref=backref(BLOG_POST_BACKREF_NAME, uselist=False, cascade="all, delete-orphan")) -- 2.25.1