当前位置: 首页>>代码示例>>Python>>正文


Python Discussion.title方法代码示例

本文整理汇总了Python中assembl.models.Discussion.title方法的典型用法代码示例。如果您正苦于以下问题:Python Discussion.title方法的具体用法?Python Discussion.title怎么用?Python Discussion.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在assembl.models.Discussion的用法示例。


在下文中一共展示了Discussion.title方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: discussion

# 需要导入模块: from assembl.models import Discussion [as 别名]
# 或者: from assembl.models.Discussion import title [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
开发者ID:assembl,项目名称:assembl,代码行数:95,代码来源:discussion.py


注:本文中的assembl.models.Discussion.title方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。