コード例 #1
0
def invite_member(portfolio_id):
    portfolio = Portfolios.get(g.current_user, portfolio_id)
    form = member_forms.NewForm(http_request.form)

    if form.validate():
        try:
            invite = Portfolios.invite(portfolio, g.current_user, form.data)
            send_portfolio_invitation(
                invitee_email=invite.email,
                inviter_name=g.current_user.full_name,
                token=invite.token,
            )

            flash("new_portfolio_member",
                  user_name=invite.user_name,
                  portfolio=portfolio)

        except AlreadyExistsError:
            return render_template(
                "error.html",
                message="There was an error processing your request.")
    else:
        pass
        # TODO: flash error message

    return redirect(
        url_for(
            "portfolios.admin",
            portfolio_id=portfolio_id,
            fragment="portfolio-members",
            _anchor="portfolio-members",
        ))
コード例 #2
0
def add_members_to_portfolio(portfolio):
    for user_data in PORTFOLIO_USERS:
        invite = Portfolios.invite(portfolio, portfolio.owner, {"user_data": user_data})
        profile = {
            k: user_data[k] for k in user_data if k not in ["dod_id", "permission_sets"]
        }
        user = Users.get_or_create_by_dod_id(user_data["dod_id"], **profile)
        PortfolioRoles.enable(invite.role, user)

    db.session.commit()
コード例 #3
0
ファイル: test_portfolios.py プロジェクト: robgil/atst
def test_invite():
    portfolio = PortfolioFactory.create()
    inviter = UserFactory.create()
    member_data = UserFactory.dictionary()

    invitation = Portfolios.invite(portfolio, inviter, member_data)

    assert invitation.role
    assert invitation.role.portfolio == portfolio
    assert invitation.role.user is None
    assert invitation.dod_id == member_data["dod_id"]