This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit cc6519eda742e81b02f79be8ef97fd185e94fcf4 Author: Dillon Walls <[email protected]> AuthorDate: Fri Jul 21 03:29:40 2023 +0000 [#8516] Discussion - delete all threads when deleted, fix attachment adding to discussion itself (unused except tests?) --- Allura/allura/model/discuss.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py index f1eeed32c..a81f822ac 100644 --- a/Allura/allura/model/discuss.py +++ b/Allura/allura/model/discuss.py @@ -127,11 +127,26 @@ class Discussion(Artifact, ActivityObject): text=self.description) return result + def attach(self, filename, fp, **kw): + """Attach a file to this Artifact. + + :param filename: file name + :param fp: a file-like object (implements ``read()``) + :param kw: passed through to Attachment class constructor + + Override's Artifact.attach to use a str artifact_id + """ + att = self.attachment_class().save_attachment( + filename=filename, + fp=fp, artifact_id=str(self._id), **kw) + return att + def delete(self): - # Delete all the threads, posts, and artifacts - self.thread_class().query.remove(dict(discussion_id=self._id)) - self.post_class().query.remove(dict(discussion_id=self._id)) - self.attachment_class().remove(dict(discussion_id=self._id)) + # Delete all the threads + for thread in self.threads: + thread.delete() + # threads handle deleting posts + # super() handles artifacts, attachments, etc. super().delete() def find_posts(self, **kw):
