Ticket #5308: 0001-Re-5308-added-cascade-to-blog-mediatype.patch

File 0001-Re-5308-added-cascade-to-blog-mediatype.patch, 1.9 KB (added by Robert, 3 years ago)
  • mediagoblin/media_types/blog/models.py

    From f67638da8e1ed78a9d787b96e8588660b0d9df7d Mon Sep 17 00:00:00 2001
    From: Robert Smith <smithrobertlawrence@gmail.com>
    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 b class BlogMixin(GenerateSlugMixin): 
    3434    def check_slug_used(self, slug):
    3535        return check_blog_slug_used(self.author, slug, self.id)
    3636
     37BLOG_BACKREF_NAME = "mediatype__blogs"
    3738
    3839class Blog(Base, BlogMixin):
    3940    __tablename__ = "mediatype__blogs"
    class Blog(Base, BlogMixin): 
    4344    author = Column(Integer, ForeignKey(User.id), nullable=False, index=True) #similar to uploader
    4445    created = Column(DateTime, nullable=False, default=datetime.datetime.now, index=True)
    4546    slug = Column(Unicode)
     47    get_author = relationship("User", backref=backref(BLOG_BACKREF_NAME, cascade="all, delete-orphan"))
    4648
    4749    @property
    4850    def slug_or_id(self):
    class Blog(Base, BlogMixin): 
    6668       
    6769   
    6870   
    69 BACKREF_NAME = "blogpost__media_data"
     71BLOG_POST_BACKREF_NAME = "blogpost__media_data"
    7072
    7173class BlogPostData(Base):
    7274    __tablename__ = "blogpost__mediadata"
    class BlogPostData(Base): 
    7577    media_entry = Column(Integer, ForeignKey('core__media_entries.id'), primary_key=True)
    7678    blog = Column(Integer, ForeignKey('mediatype__blogs.id'), nullable=False)
    7779    get_media_entry = relationship("MediaEntry",
    78         backref=backref(BACKREF_NAME, uselist=False,
     80        backref=backref(BLOG_POST_BACKREF_NAME, uselist=False,
    7981                        cascade="all, delete-orphan"))
    8082
    8183