summaryrefslogtreecommitdiffstats
path: root/bitvend/admin.py
blob: 24271de57c204bf37b13bacede3f505f3968c7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Blueprint, render_template, redirect, request, flash, url_for
from flask_login import current_user, fresh_login_required

from bitvend.models import db, Transaction
from bitvend.forms import ManualForm
from bitvend.auth import cap_required


admin_required = cap_required('staff')
bp = Blueprint('admin', __name__)

@bp.route('/manual', methods=['GET', 'POST'])
@fresh_login_required
@admin_required
def manual():
    form = ManualForm()
    if form.validate_on_submit():
        current_user.transactions.append(Transaction(
            amount=form.amount.data
            ))
        db.session.commit()
        flash('Operation successful.', 'success')

    return render_template('admin/manual.html', form=form)

@bp.route('/transactions/', defaults={'page': 1})
@bp.route('/transactions/p/<int:page>')
@fresh_login_required
@admin_required
def transactions(page):
    return render_template('admin/transactions.html',
        transactions=Transaction.query.paginate(page)
        )