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


Python Community.create方法代码示例

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


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

示例1: communities

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def communities(app, db, user):
    """Create some example communities."""
    user1 = db_.session.merge(user)

    comm0 = Community.create(community_id="comm1", user_id=user1.id, title="Title1", description="Description1")
    comm1 = Community.create(community_id="comm2", user_id=user1.id, title="A")
    comm2 = Community.create(community_id="oth3", user_id=user1.id)
    return comm0, comm1, comm2
开发者ID:krzysztof,项目名称:invenio-communities,代码行数:10,代码来源:conftest.py

示例2: communities

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def communities(app, db, user):
    """Create some example communities."""
    user1 = db_.session.merge(user)

    comm0 = Community.create(community_id='comm1', user_id=user1.id,
                             title='Title1', description='Description1')
    comm1 = Community.create(community_id='comm2', user_id=user1.id, title='A')
    comm2 = Community.create(community_id='oth3', user_id=user1.id)
    return comm0, comm1, comm2
开发者ID:inveniosoftware,项目名称:invenio-communities,代码行数:11,代码来源:conftest.py

示例3: communities

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def communities(db, users):
    """Create communities."""
    comm_data = [
        {'id': 'c1', 'user_id': users[1]['id']},
        {'id': 'c2', 'user_id': users[1]['id']},
        {'id': 'c3', 'user_id': users[0]['id']},
        {'id': 'c4', 'user_id': users[0]['id']},
    ]
    for c in comm_data:
        Community.create(c['id'], user_id=c['user_id'])
    db.session.commit()
    return comm_data
开发者ID:nikofil,项目名称:zenodo,代码行数:14,代码来源:conftest.py

示例4: loadcommunities

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def loadcommunities(owner_email):
    """Load the Zenodo communities fixture.

    Create extra PID if license is to be mapped and already exists, otherwise
    create a new license record and a PID.
    """
    data = read_json('data/communities.json')
    owner = User.query.filter_by(email=owner_email).one()

    for comm_data in data:
        community_id = comm_data.pop('id')
        user_id = owner.id
        Community.create(community_id, user_id, **comm_data)
    db.session.commit()
开发者ID:hachreak,项目名称:zenodo,代码行数:16,代码来源:communities.py

示例5: communities_for_filtering

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def communities_for_filtering(app, db, user):
    """Create some example communities."""
    user1 = db_.session.merge(user)

    comm0 = Community.create(community_id='comm1', user_id=user1.id,
                             title='Test1',
                             description=('Beautiful is better than ugly. '
                                          'Explicit is better than implicit.'))
    comm1 = Community.create(community_id='comm2', user_id=user1.id,
                             title='Testing case 2',
                             description=('Flat is better than nested. '
                                          'Sparse is better than dense.'))
    comm2 = Community.create(community_id='oth3', user_id=user1.id,
                             title='A word about testing',
                             description=('Errors should never pass silently. '
                                          'Unless explicitly silenced.'))
    return comm0, comm1, comm2
开发者ID:inveniosoftware,项目名称:invenio-communities,代码行数:19,代码来源:conftest.py

示例6: loadcommunity

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def loadcommunity(comm_data):
    """Load the Zenodo communities fixture."""
    logo_path = comm_data.pop('logo', None)
    community_id = comm_data.pop('id')
    owner_email = comm_data.pop('owner_email')
    owner_id = User.query.filter_by(email=owner_email).one().id
    c = Community.create(community_id, owner_id, **comm_data)
    if logo_path:
        logo = file_stream(logo_path)
        ext = save_and_validate_logo(logo, logo.name, community_id)
        c.logo_ext = ext
    db.session.commit()
开发者ID:slint,项目名称:zenodo,代码行数:14,代码来源:communities.py

示例7: new

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def new():
    """Create a new community."""
    form = CommunityForm(request.values)

    ctx = mycommunities_ctx()
    ctx.update({
        'form': form,
        'is_new': True,
        'community': None,
    })

    if form.validate_on_submit():
        data = copy.deepcopy(form.data)

        community_id = data.pop('identifier')
        del data['logo']

        community = Community.create(
            community_id, current_user.get_id(), **data)

        file = request.files.get('logo', None)
        if file:
            if not community.save_logo(file.stream, file.filename):
                form.logo.errors.append(_(
                    'Cannot add this file as a logo. Supported formats: '
                    'PNG, JPG and SVG. Max file size: 1.5 MB.'))
                db.session.rollback()
                community = None

        if community:
            permissions = _get_permissions()
            for permission in permissions:
                db.session.add(ActionUsers(action=permission,
                               user=current_user,
                               argument=community_id))
            db.session.commit()
            flash("{} was successfully created.".format(
                    current_app.config["COMMUNITIES_NAME"].capitalize()),
                  category='success')
            return redirect(url_for('.edit', community_id=community.id))

    return render_template(
        "/invenio_communities/new.html",
        community_form=form,
        **ctx
    )
开发者ID:tind,项目名称:invenio-communities,代码行数:48,代码来源:ui.py

示例8: test_oai_set_correspondence

# 需要导入模块: from invenio_communities.models import Community [as 别名]
# 或者: from invenio_communities.models.Community import create [as 别名]
def test_oai_set_correspondence(db, users, oai_communities, oai_sets,
                                missing_oai_set, missing_community):
    for c in oai_communities:
        with db.session.begin_nested():
            new_comm = Community.create(community_id=c, user_id=1)
        db.session.commit()

        # Delete the automatically created OAI Set id required by test case
        if new_comm.oaiset_spec not in oai_sets:
            with db.session.begin_nested():
                db.session.delete(new_comm.oaiset)
            db.session.commit()

    for s in oai_sets:
        if not OAISet.query.filter_by(spec=s).one_or_none():
            with db.session.begin_nested():
                db.session.add(OAISet(spec=s))
            db.session.commit()
    check = OAICorrespondenceCheck()
    check.perform()

    assert set(check.issues.get('missing_oai_set', [])) == set(missing_oai_set)
    assert set(check.issues.get('missing_community', [])) == \
        set(missing_community)
开发者ID:lnielsen,项目名称:zenodo,代码行数:26,代码来源:test_oai.py


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