diff options
author | Jessica Tallon <tsyesika@tsyesika.se> | 2016-02-29 14:35:30 +0000 |
---|---|---|
committer | Jessica Tallon <tsyesika@tsyesika.se> | 2016-02-29 15:40:34 +0000 |
commit | 2104c3e0f267101da35aa9d507ae6dd3a9b0c5b6 (patch) | |
tree | 3528a22e0501cbaab280404cf69929eb145a98c7 /mediagoblin/db | |
parent | 7fa67404eec307caaf682ac52e39af07425028c4 (diff) | |
download | mediagoblin-2104c3e0f267101da35aa9d507ae6dd3a9b0c5b6.tar.lz mediagoblin-2104c3e0f267101da35aa9d507ae6dd3a9b0c5b6.tar.xz mediagoblin-2104c3e0f267101da35aa9d507ae6dd3a9b0c5b6.zip |
Fix #5415 - Deleted comments get removed properly when tombstones
The original wrapper existed and should be been removed, this fix
now ensures the TextComment removes the Comment wrapper to prevent
the deleted (comments which are tombstones) existing.
Diffstat (limited to 'mediagoblin/db')
-rw-r--r-- | mediagoblin/db/models.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 38684e6f..97dc91dc 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -1008,6 +1008,17 @@ class TextComment(Base, TextCommentMixin, CommentingMixin): cascade="all, delete-orphan")) deletion_mode = Base.SOFT_DELETE + def soft_delete(self, *args, **kwargs): + # Find the GMR for this model. + gmr = GenericModelReference.query.filter_by( + obj_pk=self.id, + model_type=self.__tablename__ + ).first() + + # Delete the Comment object for this comment + Comment.query.filter_by(comment_id=gmr.id).delete() + return super(TextComment, self).soft_delete(*args, **kwargs) + def serialize(self, request): """ Unserialize to python dictionary for API """ target = self.get_reply_to() |