From: Robert Smith Date: Sat, 17 Jun 2017 06:03:20 +0000 (-0400) Subject: Re #5308 added cascade to blog mediatype X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a08f0bfc86f7a6253f0e2fa1262eff0b949057b4;p=mediagoblin.git Re #5308 added cascade to blog mediatype --- 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"))