• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.LangString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: subidea_1_1_1_1_1

def subidea_1_1_1_1_1(request, discussion, subidea_1_1_1_1, test_session):
    """An Idea fixture with a idealink to subidea_1_1_1_1 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1
                        |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_1"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Job loss", 'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_1111_11111 = IdeaLink(source=subidea_1_1_1_1, target=i)
    test_session.add(l_1111_11111)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_1_1_1_1_1"
        test_session.delete(l_1111_11111)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
开发者ID:assembl,项目名称:assembl,代码行数:26,代码来源:ideas.py


示例2: subidea_1_1_1_1_2_2

def subidea_1_1_1_1_2_2(request, discussion, subidea_1_1_1_1_2, test_session):
    """An Idea fixture with a idealink to subidea_1_1_1_1_2 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1
                        |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_2
                                |-> subidea_1_1_1_1_2_1
                                |-> subidea_1_1_1_1_2_2"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Federal programs are ineffective", 'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_11112_111122 = IdeaLink(source=subidea_1_1_1_1_2, target=i)
    test_session.add(l_11112_111122)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_1_1_1_2_2"
        test_session.delete(l_11112_111122)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
开发者ID:assembl,项目名称:assembl,代码行数:29,代码来源:ideas.py


示例3: subidea_1_1_1

def subidea_1_1_1(request, discussion, subidea_1_1, test_session):
    """An Idea fixture with a idealink to subidea_1_1 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1"""

    from assembl.models import Idea, IdeaLink, LangString
    title = LangString.create(u"Lower government revenue", 'en')
    title.add_value(u'Moins de revenus pour le gouvernement', 'fr')
    i = Idea(title=title,
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_11_111 = IdeaLink(source=subidea_1_1, target=i)
    test_session.add(l_11_111)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_1_1"
        test_session.delete(l_11_111)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
开发者ID:assembl,项目名称:assembl,代码行数:26,代码来源:ideas.py


示例4: timeline_vote_session

def timeline_vote_session(request, test_session, discussion):
    from assembl.models import DiscussionPhase, LangString

    phase = DiscussionPhase(
        discussion=discussion,
        identifier='voteSession',
        title=LangString.create(u"voteSession phase title fixture", "en"),
        description=LangString.create(u"voteSession phase description fixture", "en"),
        start=datetime(2014, 12, 31, 9, 0, 0),
        end=datetime(2015, 12, 31, 9, 0, 0),
        interface_v1=False,
        image_url=u'https://example.net/image.jpg'
    )


    # Create the phase
    test_session.add(phase)
    test_session.flush()

    def fin():
        print "finalizer timeline"
        test_session.delete(phase)
        test_session.flush()

    request.addfinalizer(fin)
    return phase
开发者ID:assembl,项目名称:assembl,代码行数:26,代码来源:timeline.py


示例5: post_related_to_sub_idea_1

def post_related_to_sub_idea_1(
        request, test_session, discussion, admin_user, subidea_1):
    from assembl.models import Post, LangString, IdeaRelatedPostLink
    idea = subidea_1
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"A post related to sub_idea_1 "),
        body=LangString.create(u"A post related to sub_idea_1"),
        type='post', message_id="[email protected]")

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer root_post_en_under_positive_column_of_idea"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
开发者ID:assembl,项目名称:assembl,代码行数:27,代码来源:posts.py


示例6: post_related_to_sub_idea_1_1_1

def post_related_to_sub_idea_1_1_1(
        request, test_session, discussion, admin_user, subidea_1_1_1):
    from assembl.models import Post, LangString, IdeaRelatedPostLink
    idea = subidea_1_1_1
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"A post subject related to sub_idea_1_1_1"),
        body=LangString.create(u"A post body related to sub_idea_1_1_1"),
        creation_date=datetime(2018, 2, 17, 9, 0, 0),  # in the thread phase date range (see phases fixture)
        type='post', message_id="[email protected]")

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer post_related_to_sub_idea_1_1_1"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
开发者ID:assembl,项目名称:assembl,代码行数:28,代码来源:posts.py


示例7: root_post_en_under_positive_column_of_idea

def root_post_en_under_positive_column_of_idea(
        request, test_session, discussion, admin_user,
        idea_message_column_positive):
    from assembl.models import Post, LangString, IdeaRelatedPostLink
    idea = idea_message_column_positive.idea
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"A simple positive subject"),
        body=LangString.create(u"A simple positive body"),
        type='post', message_id="[email protected]",
        message_classifier=idea_message_column_positive.message_classifier)

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer root_post_en_under_positive_column_of_idea"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
开发者ID:assembl,项目名称:assembl,代码行数:29,代码来源:posts.py


示例8: post_draft_for_bright_mirror

def post_draft_for_bright_mirror(
        request, test_session, discussion, moderator_user,
        bright_mirror):
    from assembl.models import Post, Idea, LangString, IdeaRelatedPostLink, PublicationStates
    from graphene.relay import Node
    idea_id = bright_mirror
    raw_id = int(Node.from_global_id(idea_id)[1])
    idea = Idea.get(raw_id)
    p = Post(
        discussion=discussion, creator=moderator_user,
        subject=LangString.create(u"Draft"),
        body=LangString.create(u"A simple draft fiction"),
        type='post', publication_state=PublicationStates.DRAFT,
        message_id="[email protected]",
        creation_date = datetime.utcnow() - timedelta(days=7))

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=moderator_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer post_draft_for_bright_mirror"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
开发者ID:assembl,项目名称:assembl,代码行数:33,代码来源:bright_mirror.py


示例9: idea_message_column_negative_on_subidea_1_1

def idea_message_column_negative_on_subidea_1_1(request, test_adminuser_webrequest, subidea_1_1, test_session):
    from assembl.models import IdeaMessageColumn, LangString

    column = IdeaMessageColumn(idea=subidea_1_1,
                               message_classifier='negative',
                               name=LangString.create('Say my name', 'en'),
                               title=LangString.create('Add your point of view against the theme', 'en'),
                               color="red")

    test_session.add(column)
    synthesis = column.create_column_synthesis(
        subject=LangString.create('Be negative!', 'en'),
        body=LangString.create('This is a negative header', 'en'),
        creator_id=test_adminuser_webrequest.authenticated_userid
    )
    test_session.flush()

    def fin():
        test_session.delete(synthesis)
        test_session.delete(synthesis.idea_links_of_content[0])
        test_session.delete(column)
        test_session.flush()

    request.addfinalizer(fin)
    return column
开发者ID:assembl,项目名称:assembl,代码行数:25,代码来源:idea_message_columns.py


示例10: creativity_session_widget_post

def creativity_session_widget_post(
        request, test_session, discussion, participant1_user,
        creativity_session_widget, creativity_session_widget_new_idea):
    """A Post fixture with a bound to a creativity widget to a new idea and
    an idea content link"""

    from assembl.models import (Post, IdeaContentWidgetLink, LangString)
    p = Post(
        discussion=discussion, creator=participant1_user,
        subject=LangString.create(u"re: generated idea"),
        body=LangString.create(u"post body"),
        type="post", message_id="[email protected]")
    test_session.add(p)
    test_session.flush()
    icwl = IdeaContentWidgetLink(
        content=p, idea=creativity_session_widget_new_idea,
        creator=participant1_user)
    test_session.add(icwl)

    def fin():
        print "finalizer creativity_session_widget_post"
        test_session.delete(icwl)
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)

    return p
开发者ID:assembl,项目名称:assembl,代码行数:27,代码来源:creativity_session.py


示例11: creativity_session_widget_new_idea

def creativity_session_widget_new_idea(
        request, test_session, discussion, subidea_1,
        creativity_session_widget, participant1_user):
    """An Idea fixture with an bound ideaLink,
    GeneratedIdeaWidgetLink, and a IdeaProposalPost"""

    from assembl.models import (Idea, IdeaLink, GeneratedIdeaWidgetLink,
                                IdeaProposalPost, LangString)
    i = Idea(
        discussion=discussion,
        title=LangString.create(u"generated idea", 'en'))
    test_session.add(i)
    l_1_wi = IdeaLink(source=subidea_1, target=i)
    test_session.add(l_1_wi)
    l_w_wi = GeneratedIdeaWidgetLink(
        widget=creativity_session_widget,
        idea=i)
    ipp = IdeaProposalPost(
        proposes_idea=i, creator=participant1_user, discussion=discussion,
        message_id='[email protected]',
        subject=LangString.create(u"propose idea"),
        body=LangString.EMPTY(test_session))
    test_session.add(ipp)

    def fin():
        print "finalizer creativity_session_widget_new_idea"
        test_session.delete(ipp)
        test_session.delete(l_w_wi)
        test_session.delete(l_1_wi)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)

    return i
开发者ID:assembl,项目名称:assembl,代码行数:34,代码来源:creativity_session.py


示例12: post_body_locale_determined_by_import

def post_body_locale_determined_by_import(
        request, test_session, discussion, admin_user, mailbox,
        undefined_locale, fr_locale, en_locale):
    from assembl.models import Email, LangString
    p = Email(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"testa"),
        body=LangString.create(u"testa"),
        source=mailbox,
        body_mime_type="text/plain",
        sender="[email protected]",
        recipients="[email protected]",
        message_id="[email protected]",
        imported_blob="""Subject: testa
From: Mr. Administrator <[email protected]>
Content-Language: fr
Content-Type: text/plain; charset="iso-8859-1"

testa""")
    # must be done after the source is set
    p.source_post_id = "[email protected]"
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer post_subject_locale_determined_by_creator"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
开发者ID:assembl,项目名称:assembl,代码行数:30,代码来源:posts.py


示例13: post_published_for_bright_mirror_participant

def post_published_for_bright_mirror_participant(
        request, test_session, discussion, admin_user, participant1_user,
        bright_mirror):
    from assembl.models import Post, Idea, LangString, IdeaRelatedPostLink, PublicationStates
    from graphene.relay import Node
    idea_id = bright_mirror
    raw_id = int(Node.from_global_id(idea_id)[1])
    idea = Idea.get(raw_id)
    p = Post(
        discussion=discussion, creator=participant1_user,
        subject=LangString.create(u"Published by participant"),
        body=LangString.create(u"A simple published fiction by participant"),
        type='post', publication_state=PublicationStates.PUBLISHED,
        message_id="[email protected]",
        creation_date = datetime.utcnow())

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer post_published_for_bright_mirror"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
开发者ID:assembl,项目名称:assembl,代码行数:33,代码来源:bright_mirror.py


示例14: fin

 def fin():
     print "finalizer db_default_data"
     session = db_tables()
     clear_rows(get_config(), session)
     transaction.commit()
     from assembl.models import Locale, LangString
     Locale.reset_cache()
     LangString.reset_cache()
开发者ID:festrade,项目名称:assembl,代码行数:8,代码来源:base.py


示例15: test_add_resource

def test_add_resource(admin_user, discussion, test_session):
    from assembl.models.resource import Resource
    from assembl.models import LangString

    resource = Resource(
        discussion_id=discussion.id,
        title=LangString.create(u"a resource"),
        text=LangString.create(u"Lorem ipsum dolor sit amet"),
        embed_code=u"<iframe ...>",
        order=3.0
    )

    assert resource.title.entries[0].value == u'a resource'
    assert resource.text.entries[0].value == u'Lorem ipsum dolor sit amet'
    assert resource.embed_code == u"<iframe ...>"
    assert resource.order == 3.0
开发者ID:assembl,项目名称:assembl,代码行数:16,代码来源:test_resource.py


示例16: sections

def sections(request, discussion_with_default_data, test_session):
    """Create default sections."""
    from assembl.models import Section, LangString
    from assembl.models.section import SectionTypesEnum
    discussion_id = discussion_with_default_data.id

    # default sections are created in the discussion_with_default_data fixture
    # via create_default_discussion_data

    sections = []
    # add a custom section
    custom_section = Section(
        discussion_id=discussion_id,
        title=LangString.create(u'GNU is not Unix', 'en'),
        url=u'http://www.gnu.org',
        section_type=SectionTypesEnum.CUSTOM.value,
        order=4.0
    )
    sections.append(custom_section)

    for section in sections:
        test_session.add(section)
    test_session.flush()

    def fin():
        print "finalizer sections"
        for section in sections:
            test_session.delete(section)
        test_session.flush()
    request.addfinalizer(fin)

    return sections
开发者ID:assembl,项目名称:assembl,代码行数:32,代码来源:sections.py


示例17: save_synthesis

def save_synthesis(request):
    synthesis_id = request.matchdict['id']
    discussion_id = int(request.matchdict['discussion_id'])
    if synthesis_id == 'next_synthesis':
        discussion = Discussion.get_instance(discussion_id)
        synthesis = discussion.get_next_synthesis()
    else:
        synthesis = Synthesis.get_instance(synthesis_id)
    if not synthesis:
        raise HTTPBadRequest("Synthesis with id '%s' not found." % synthesis_id)

    synthesis_data = json.loads(request.body)
    user_id = request.authenticated_userid
    permissions = get_permissions(user_id, discussion_id)

    for key in ('subject', 'introduction', 'conclusion'):
        if key in synthesis_data:
            ls_data = synthesis_data[key]
            if ls_data is None:
                continue
            assert isinstance(ls_data, dict)
            current = LangString.create_from_json(
                ls_data, user_id, permissions=permissions)
            setattr(synthesis, key, current)

    Synthesis.default_db.add(synthesis)
    Synthesis.default_db.flush()

    return {'ok': True, 'id': synthesis.uri()}
开发者ID:assembl,项目名称:assembl,代码行数:29,代码来源:synthesis.py


示例18: create_idea

def create_idea(request):
    discussion_id = int(request.matchdict['discussion_id'])
    session = Discussion.default_db
    discussion = session.query(Discussion).get(int(discussion_id))
    user_id = request.authenticated_userid
    permissions = get_permissions(user_id, discussion.id)
    idea_data = json.loads(request.body)
    kwargs = {
        "discussion": discussion
    }

    for key, attr_name in langstring_fields.iteritems():
        if key in idea_data:
            ls_data = idea_data[key]
            if ls_data is None:
                continue
            assert isinstance(ls_data, dict)
            current = LangString.create_from_json(
                ls_data, user_id, permissions=permissions)
            kwargs[attr_name] = current

    new_idea = Idea(**kwargs)

    session.add(new_idea)

    if idea_data['parentId']:
        parent = Idea.get_instance(idea_data['parentId'])
    else:
        parent = discussion.root_idea
    session.add(IdeaLink(source=parent, target=new_idea, order=idea_data.get('order', 0.0)))

    session.flush()

    return {'ok': True, '@id': new_idea.uri()}
开发者ID:assembl,项目名称:assembl,代码行数:34,代码来源:idea.py


示例19: extract_comment

def extract_comment(request, extract_post_1_to_subidea_1_1, discussion, admin_user, test_session):
    from assembl.models import ExtractComment, LangString
    p = ExtractComment(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"comment of extract title"),
        body=LangString.create(u"comment of extract body"),
        message_id="[email protected]",
        parent_extract_id=extract_post_1_to_subidea_1_1.id)
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer post_subject_locale_determined_by_creator"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
开发者ID:assembl,项目名称:assembl,代码行数:17,代码来源:posts.py


示例20: test_add_discussion

def test_add_discussion(test_session):
    d = Discussion(
        topic=u"Education", slug="education",
        subscribe_to_notifications_on_signup=False,
        creator=None,
        session=test_session)
    d.discussion_locales = ['en', 'fr', 'de']
    d.terms_and_conditions = LangString.create(
        u"Use the haptic JSON system, then you can quantify the cross-platform capacitor!", "en")
    d.legal_notice = LangString.create(
        u"Use the optical SCSI microchip, then you can generate the cross-platform pixel!", "en")
    test_session.flush()
    assert d.topic == u"Education"
    assert d.discussion_locales == ['en', 'fr', 'de']
    assert d.terms_and_conditions.entries[0].value == u"Use the haptic JSON system, then you can quantify the cross-platform capacitor!"  # noqa: E501
    assert d.legal_notice.entries[0].value == u"Use the optical SCSI microchip, then you can generate the cross-platform pixel!"  # noqa: E501
    test_session.delete(d)
开发者ID:assembl,项目名称:assembl,代码行数:17,代码来源:test_discussion.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Post类代码示例发布时间:2022-05-24
下一篇:
Python models.Idea类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap