Re #5308 added cascade to blog mediatype
authorRobert Smith <smithrobertlawrence@gmail.com>
Sat, 17 Jun 2017 06:03:20 +0000 (02:03 -0400)
committerBoris Bobrov <breton@cynicmansion.ru>
Sun, 18 Jun 2017 10:40:50 +0000 (13:40 +0300)
(cherry picked from commit a08f0bfc86f7a6253f0e2fa1262eff0b949057b4)

mediagoblin/media_types/blog/models.py

index 0e1ddf974350f3f72ce724655a63a167b76a5f85..83f520c7ae86a9aad288574bd2f221bb59bf84ea 100644 (file)
@@ -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"))