You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/04/13 17:42:54 UTC
[allura] 02/50: [#7935] added annotate method
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 63665beaf454489161a5857d1c0bdd38770d0c9e
Author: Korkmatik <fa...@protonmail.ch>
AuthorDate: Sun Dec 22 00:51:37 2019 +0100
[#7935] added annotate method
---
ForgeImporters/forgeimporters/forge/discussion.py | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/ForgeImporters/forgeimporters/forge/discussion.py b/ForgeImporters/forgeimporters/forge/discussion.py
index 754f1d9..aa7ec3c 100644
--- a/ForgeImporters/forgeimporters/forge/discussion.py
+++ b/ForgeImporters/forgeimporters/forge/discussion.py
@@ -50,6 +50,7 @@ class ForgeDiscussionImportController(ToolImportController):
@require_post()
def create(self, discussions_json, mount_point, mount_label, **kw):
# TODO: delete debug output
+ self.importer.clear_pending(c.project) # TODO: Delete this line
if self.importer.enforce_limit(c.project):
print("import 1")
save_importer_upload(c.project, 'discussion.json', json.dumps(discussions_json))
@@ -108,7 +109,7 @@ class ForgeDiscussionImporter(ToolImporter):
new_forum = dict(
shortname=forum_json['shortname'],
- _id=forum_json['_id'],
+ _id=forum_json.get('_id', ''),
description=forum_json['description'],
name=forum_json['name'],
create='on',
@@ -123,16 +124,10 @@ class ForgeDiscussionImporter(ToolImporter):
forum = utils.create_forum(app, new_forum=new_forum)
for thread_json in forum_json["threads"]:
- #thread = DM.ForumThread(
- # _id=thread_json['_id'],
- # discussion_id=thread_json['discussion_id'],
- # subject=thread_json['subject']
- #)
thread = forum.get_discussion_thread(dict(
headers=dict(Subject=thread_json['subject'])))[0]
- self.add_posts(
- thread, thread_json['posts'])
+ self.add_posts(thread, thread_json['posts'])
session(forum).flush(forum)
session(forum).expunge(forum)
@@ -157,7 +152,9 @@ class ForgeDiscussionImporter(ToolImporter):
return user
def annotate(self, text, user, username, label=''):
- pass
+ if username and user.is_anonymous() and username != 'nobody':
+ return '*Originally%s by:* %s\n\n%s' % (label, username, text)
+ return text
def add_posts(self, thread, posts):
for post_json in posts: