def records(): db.create_all() page = request.args.get('page', 1, type=int) visi_irasai = Irasas.query.filter_by( vartotojas_id=current_user.id).order_by(Irasas.data.asc()).paginate( page=page, per_page=5) return render_template("irasai.html", visi_irasai=visi_irasai, datetime=datetime)
def new_record(): db.create_all() forma = forms.IrasasForm() if forma.validate_on_submit(): naujas_irasas = Irasas(pajamos=forma.pajamos.data, suma=forma.suma.data, vartotojas_id=current_user.id) db.session.add(naujas_irasas) db.session.commit() flash(f"Įrašas sukurtas", 'success') return redirect(url_for('records')) return render_template("prideti_irasa.html", form=forma)
def registruotis(): db.create_all() if current_user.is_authenticated: return redirect(url_for('index')) form = forms.RegistracijosForma() if form.validate_on_submit(): vartotojas = Vartotojas(vardas=form.vardas.data, el_pastas=form.el_pastas.data, slaptazodis=form.slaptazodis.data) db.session.add(vartotojas) db.session.commit() flash('Sėkmingai prisiregistravote! Galite prisijungti', 'success') return redirect(url_for('index')) return render_template('registruotis.html', title='Register', form=form)
from biudzetas import app, db if __name__ == '__main__': app.run(debug=True) # app.run(host='127.0.0.1', port=8000, debug=True) db.create_all()