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):
|
34 | 34 | def check_slug_used(self, slug): |
35 | 35 | return check_blog_slug_used(self.author, slug, self.id) |
36 | 36 | |
| 37 | BLOG_BACKREF_NAME = "mediatype__blogs" |
37 | 38 | |
38 | 39 | class Blog(Base, BlogMixin): |
39 | 40 | __tablename__ = "mediatype__blogs" |
… |
… |
class Blog(Base, BlogMixin):
|
43 | 44 | author = Column(Integer, ForeignKey(User.id), nullable=False, index=True) #similar to uploader |
44 | 45 | created = Column(DateTime, nullable=False, default=datetime.datetime.now, index=True) |
45 | 46 | slug = Column(Unicode) |
| 47 | get_author = relationship("User", backref=backref(BLOG_BACKREF_NAME, cascade="all, delete-orphan")) |
46 | 48 | |
47 | 49 | @property |
48 | 50 | def slug_or_id(self): |
… |
… |
class Blog(Base, BlogMixin):
|
66 | 68 | |
67 | 69 | |
68 | 70 | |
69 | | BACKREF_NAME = "blogpost__media_data" |
| 71 | BLOG_POST_BACKREF_NAME = "blogpost__media_data" |
70 | 72 | |
71 | 73 | class BlogPostData(Base): |
72 | 74 | __tablename__ = "blogpost__mediadata" |
… |
… |
class BlogPostData(Base):
|
75 | 77 | media_entry = Column(Integer, ForeignKey('core__media_entries.id'), primary_key=True) |
76 | 78 | blog = Column(Integer, ForeignKey('mediatype__blogs.id'), nullable=False) |
77 | 79 | get_media_entry = relationship("MediaEntry", |
78 | | backref=backref(BACKREF_NAME, uselist=False, |
| 80 | backref=backref(BLOG_POST_BACKREF_NAME, uselist=False, |
79 | 81 | cascade="all, delete-orphan")) |
80 | 82 | |
81 | 83 | |