Esempio n. 1
0
def start_password_reset(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    if request.method == 'POST':
        user.password_reset_uuid = str(uuid.uuid4())
        user.save()
        flash('User password reset engaged.', 'info')
        return redirect(url_for('admin.edit_user', user_id=user_id))

    return redirect(url_for('admin.edit_user', user_id=user_id))
Esempio n. 2
0
def start_password_reset(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    if request.method == 'POST':
        user.password_reset_uuid = str(uuid.uuid4())
        user.save()
        flash('User password reset engaged.', 'info')
        return redirect(url_for('admin.edit_user', user_id=user_id))

    return redirect(url_for('admin.edit_user', user_id=user_id))
Esempio n. 3
0
def edit_user(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    form = EditUserForm(request.form, departments=[d.id for d in user.departments])
    form.departments.choices = [(d.id, d.name) for d in Department.query.order_by('name')]

    if request.method == 'POST':
        user.departments = [Department.get_by_id(int(d)) for d in form.departments.data]
        user.save()
        flash('User updated.', 'info')
        return redirect(url_for('admin.admin_dashboard'))

    return render_template("admin/editUser.html", form=form, user=user)
Esempio n. 4
0
def edit_user(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    form = EditUserForm(request.form,
                        departments=[d.id for d in user.departments])
    form.departments.choices = [(d.id, d.name)
                                for d in Department.query.order_by('name')]

    if request.method == 'POST':
        user.departments = [
            Department.get_by_id(int(d)) for d in form.departments.data
        ]
        user.save()
        flash('User updated.', 'info')
        return redirect(url_for('admin.admin_dashboard'))

    return render_template("admin/editUser.html", form=form, user=user)
Esempio n. 5
0
def load_user(id):
    return User.get_by_id(int(id))
Esempio n. 6
0
def load_user(id):
    return User.get_by_id(int(id))
    def test_get_by_id(self):
        user = User('foo', '*****@*****.**')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user
Esempio n. 8
0
    def test_get_by_id(self):
        user = User('foo', '*****@*****.**')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user