def METHOD_NAME(community, fix=False):
    """Create community admin and member roles and add their permissions.
    :param community: the community for which we add the roles and
        permissions.
    :param fix: Enable the fixing of the database. This function doesn't fail
        if some roles or permissions already exist. It will just add the
        missing ones.
    """
    from b2share.modules.deposit.permissions import (
        create_deposit_need_factory, read_deposit_need_factory,
        update_deposit_metadata_need_factory,
        update_deposit_publication_state_need_factory,
    )
    from b2share.modules.deposit.api import PublicationStates
    from b2share.modules.records.permissions import (
        update_record_metadata_need_factory,
    )
    from b2share.modules.users.permissions import (
        assign_role_need_factory, search_accounts_need,
    )
    admin_role = Role(
        name=_community_admin_role_name(community),
        description='Admin role of the community "{}"'.format(community.name)
    )
    member_role = Role(
        name=_community_member_role_name(community),
        description='Member role of the community "{}"'.format(community.name)
    )
    # use a nested session so that the ids are generated by the DB.
    with db.session.begin_nested():
        admin_role = add_to_db(admin_role, skip_if_exists=fix)
        member_role = add_to_db(member_role, skip_if_exists=fix)
    member_needs = [
        create_deposit_need_factory(str(community.id)),
    ]
    admin_needs = [
        read_deposit_need_factory(
            community=str(community.id),
            publication_state=PublicationStates.submitted.name
        ),
        read_deposit_need_factory(
            community=str(community.id),
            publication_state=PublicationStates.published.name
        ),
        update_deposit_metadata_need_factory(
            community=str(community.id),
            publication_state=PublicationStates.submitted.name
        ),
        # permission to publish a submission
        update_deposit_publication_state_need_factory(
            community=str(community.id),
            old_state=PublicationStates.submitted.name,
            new_state=PublicationStates.published.name
        ),
        # permission to ask the owners to fix a submission before resubmitting
        update_deposit_publication_state_need_factory(
            community=str(community.id),
            old_state=PublicationStates.submitted.name,
            new_state=PublicationStates.draft.name
        ),
        # permission to update the metadata of a published record
        update_record_metadata_need_factory(
            community=str(community.id),
        ),
        # allow to assign any role owned by this community
        assign_role_need_factory(community=community.id),
        # allow to list users' accounts
        search_accounts_need,
    ]
    for need in member_needs:
        add_to_db(ActionRoles.allow(need, role=member_role),
                  skip_if_exists=fix,
                  role_id=member_role.id)
    for need in chain (member_needs, admin_needs):
        add_to_db(ActionRoles.allow(need, role=admin_role),
                  skip_if_exists=fix,
                  role_id=admin_role.id)