Commit 5b96b0de authored by Romain Courteaud's avatar Romain Courteaud

romain_dev: create fake threads

parent 87b1a309
project_count = 100
thread_per_project_count = 100
post_per_thread_amount = 97
max_new_document = 100
tag = 'POPULATE_FORUM'
if (current_project_uid is None) and (created_project_count < project_count):
created_project_count += 1
created_thread_count = 0
created_post_count = 0
# no project, create
project = context.project_module.newContent(
portal_type='Project',
title='Forum project %i' % created_project_count,
activate_kw={'tag': tag}
)
return context.activate(after_tag=tag).testromain(
current_project_uid=project.getUid(),
created_project_count=created_project_count
)
if (current_thread_path is None) and (created_thread_count < thread_per_project_count):
created_thread_count += 1
thread = context.discussion_thread_module.newContent(
portal_type='Discussion Thread',
title='Forum project %i discussion %i' % (created_project_count, created_thread_count),
follow_up_uid=current_project_uid,
activate_kw={'tag': tag}
)
thread.share()
return context.activate(after_tag=tag).testromain(
current_project_uid=current_project_uid,
current_thread_path=thread.getRelativeUrl(),
created_project_count=created_project_count,
created_thread_count=created_thread_count
)
if (current_thread_path is not None):
if (created_post_count < post_per_thread_amount):
for i in range(max_new_document):
created_post_count += 1
thread = context.restrictedTraverse(current_thread_path)
post = thread.newContent(
portal_type='Discussion Post',
text_content="<p>Post %i</p><pre><code>def couscous:\n return getTructruc()</code></pre><a href='https://www.nexedi.com'>Nexedi</a><img src='https://www.nexedi.com/img/nexedi-logo.png'></img><p>👍</p>" % created_post_count,
activate_kw={'tag': tag}
)
# post.share()
return context.activate(after_tag=tag).testromain(
current_project_uid=current_project_uid,
current_thread_path=current_thread_path,
created_project_count=created_project_count,
created_thread_count=created_thread_count,
created_post_count=created_post_count
)
else:
return context.activate(after_tag=tag).testromain(
current_project_uid=current_project_uid,
created_project_count=created_project_count,
created_thread_count=created_thread_count
)
return "ok"
context.setTitle("Prénom".decode("utf-8").encode("iso-8859-1"))
return "ok"
from AccessControl import getSecurityManager
from pprint import pformat
# vgetattr = context.test_vincent_getattr
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
<value> <string>current_project_uid=None, current_thread_path=None, created_project_count=0, created_thread_count=0, created_post_count=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment