Пример #1
0
def test_double_email_deliver(app):
    email = "*****@*****.**"
    test_invite = UserInvitation.new_invite(email)
    with mail.record_messages() as outbox:
        UserInvitation.deliver_invite(test_invite)
        UserInvitation.deliver_invite(test_invite)
    assert len(outbox) == 2
    db.session.rollback()
Пример #2
0
def test_new_email_invite(app):
    email = "*****@*****.**"
    test_invite = UserInvitation.new_invite(email)
    with mail.record_messages() as outbox:
        UserInvitation.deliver_invite(test_invite)
    assert test_invite.email in outbox[0].recipients
    assert test_invite.token in outbox[0].body
    assert UserInvitation.get_invite(test_invite.token)
    test_invite.accept_invite()
    assert test_invite.accepted_date
    assert test_invite.is_expired
    db.session.rollback()
Пример #3
0
def test_new_anonymous_invite(app):
    test_invite = UserInvitation.new_invite()
    assert test_invite.token in UserInvitation.deliver_invite(test_invite)
    assert not test_invite.is_expired
    assert not test_invite.is_admin
    assert UserInvitation.get_invite(test_invite.token)
    test_invite.accept_invite()
    assert test_invite.accepted_date
    assert test_invite.is_expired
    db.session.rollback()
Пример #4
0
def new_user(email, admin):
    ensure_server_name()

    if email and User.exists(email):
        raise click.BadParameter(f"{email} already exists")

    invite = UserInvitation.new_invite(email=email, is_admin=admin)
    msg = UserInvitation.deliver_invite(invite)
    db.session.commit()
    print(msg)
Пример #5
0
def users():
    users = User.query.all()
    inviteForm = forms.InviteUserForm()
    if inviteForm.validate_on_submit():
        invitation = UserInvitation.new_invite(inviteForm.email.data)
        msg = UserInvitation.deliver_invite(invitation)
        flash(msg, "success")
        db.session.commit()
        return redirect(url_for("admin.users"))
    return render_template(
        "admin/users.html",
        users=users,
        delForm=forms.UserDeleteForm(),
        editForm=forms.UserEditForm(),
        inviteForm=inviteForm,
    )
Пример #6
0
def test_double_anonymous_deliver(app):
    test_invite = UserInvitation.new_invite()
    assert test_invite.token in UserInvitation.deliver_invite(test_invite)
    assert test_invite.token in UserInvitation.deliver_invite(test_invite)
    db.session.rollback()
Пример #7
0
def new_invite(email=None, admin=False):
    invite = UserInvitation.new_invite(email=email, is_admin=admin)
    msg = UserInvitation.deliver_invite(invite)
    print(msg)