本文整理汇总了Python中assembl.models.Discussion.button_label方法的典型用法代码示例。如果您正苦于以下问题:Python Discussion.button_label方法的具体用法?Python Discussion.button_label怎么用?Python Discussion.button_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assembl.models.Discussion
的用法示例。
在下文中一共展示了Discussion.button_label方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: discussion
# 需要导入模块: from assembl.models import Discussion [as 别名]
# 或者: from assembl.models.Discussion import button_label [as 别名]
def discussion(request, test_session, participant2_user, default_preferences):
"""An empty Discussion fixture with default preferences"""
from assembl.models import Discussion, DiscussionAttachment, File, LangString, AttachmentPurpose
# from assembl.lib.migration import create_default_discussion_data
with test_session.no_autoflush:
d = Discussion(
topic=u"Jack Layton", slug="jacklayton2",
subscribe_to_notifications_on_signup=False,
creator=None,
session=test_session)
d.discussion_locales = ['en', 'fr', 'de']
d.legal_notice = LangString.create(
u"We need to input the optical HDD sensor!", "en")
tac = LangString.create(
u"You can't quantify the driver without quantifying the 1080p JSON protocol!", "en")
tac.add_value(
u"Vous ne pouvez pas mesurer le driver sans mesurer le protocole JSON en 1080p", u"fr")
d.terms_and_conditions = tac
title = LangString.create(
u"Faut-il manger des bananes ?", u"fr")
title.add_value(
u"Should we eat bananas?", u"en")
d.title = title
subtitle = LangString.create(
u"Dis-moi ce que tu manges et je te dirai qui tu es", u"fr")
subtitle.add_value(
u"Tell me what you eat and I will tell you who you are", u"en")
d.subtitle = subtitle
button_label = LangString.create(
u"Discuter des bananes", u"fr")
button_label.add_value(
u"Discuss bananas", u"en")
d.button_label = button_label
# add a privacy policy attachment to the discussion
document = File(
discussion=d,
mime_type='image/png',
title='simple_image.png'
)
test_session.add(document)
document.add_raw_data(os.urandom(256))
test_session.add(document)
attachment = DiscussionAttachment(
discussion=d,
document=document,
creator_id=participant2_user.id,
title='A privacy policy attachment',
attachmentPurpose=AttachmentPurpose.PRIVACY_POLICY_ATTACHMENT.value
)
test_session.add(attachment)
test_session.add(d)
# create_default_discussion_data(d)
# Don't create default discussion data (permissions, sections) here
# because it takes too much time to run all tests.
# If you need sections or permissions in your tests, execute
# create_default_discussion_data, create_default_discussion_sections
# or create_default_permissions in your specific test or
# use discussion_with_default_data fixture.
# If you do permissions tests, be aware that the admin user
# having R_SYSADMIN is actually a special case, see
# auth/utils.py:get_permissions, it doesn't use discussion permissions
# at all. So you need discussion permissions if you test with the
# unauthenticated user Everyone or a user not having the R_SYSADMIN role.
test_session.flush()
def fin():
print "finalizer discussion"
discussion = d
if inspect(discussion).detached:
# How did this happen?
discussion = test_session.query(Discussion).get(d.id)
test_session.delete(attachment)
test_session.delete(document)
test_session.delete(discussion.table_of_contents)
test_session.delete(discussion.root_idea)
test_session.delete(discussion.next_synthesis)
preferences = discussion.preferences
discussion.preferences = None
discussion.preferences_id = None
for ut in discussion.user_templates:
for ns in ut.notification_subscriptions:
ns.delete()
ut.delete()
test_session.delete(preferences)
test_session.delete(discussion)
test_session.flush()
request.addfinalizer(fin)
return d