52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
|
from flask import render_template, redirect, request, url_for, flash, session, abort, current_app
|
||
|
from flask_login import login_required, login_user, logout_user, current_user
|
||
|
from sqlalchemy import desc
|
||
|
|
||
|
from . import settings
|
||
|
from .forms import EditProfileForm, EditProfileAdminForm, ChargeForm, PaymentForm
|
||
|
|
||
|
from ..email import send_email
|
||
|
from .. import db
|
||
|
from ..models import User, Order
|
||
|
|
||
|
#PROFILE
|
||
|
@settings.route('/profile', methods=['GET', 'POST'])
|
||
|
@login_required
|
||
|
def profile():
|
||
|
page = { 'title': 'Edit Profile' }
|
||
|
|
||
|
currentmail = current_user.email
|
||
|
ouruser = User.query.filter_by(email=currentmail).first()
|
||
|
db.session.commit()
|
||
|
|
||
|
#wallet = "%.2f" % round(ouruser.wallet, 3)
|
||
|
#print(wallet)
|
||
|
|
||
|
form = EditProfileForm()
|
||
|
if form.validate_on_submit():
|
||
|
current_user.name = form.name.data
|
||
|
current_user.address = form.address.data
|
||
|
current_user.city = form.city.data
|
||
|
current_user.postcode = form.postcode.data
|
||
|
current_user.country = form.country.data
|
||
|
current_user.phone = form.phone.data
|
||
|
current_user.org_responsible = form.org_responsible.data
|
||
|
current_user.org_bulstat = form.org_bulstat.data
|
||
|
current_user.twofactor = form.twofactor.data
|
||
|
db.session.add(current_user)
|
||
|
db.session.commit()
|
||
|
flash('Info Updated!')
|
||
|
|
||
|
form.twofactor.data = current_user.twofactor
|
||
|
form.name.data = current_user.name
|
||
|
form.address.data = current_user.address
|
||
|
form.city.data = current_user.city
|
||
|
form.postcode.data = current_user.postcode
|
||
|
form.country.data = current_user.country
|
||
|
form.phone.data = current_user.phone
|
||
|
form.org_responsible.data = current_user.org_responsible
|
||
|
form.org_bulstat.data = current_user.org_bulstat
|
||
|
|
||
|
return render_template('settings/profile.html', page=page, form=form)
|
||
|
|