template fixes

This commit is contained in:
deflax 2017-06-25 17:11:52 +03:00
parent d7af4c92a4
commit ec3b775cd8
20 changed files with 86 additions and 84 deletions

View file

@ -38,8 +38,8 @@ def index():
@login_required
@admin_required
def list_items():
alldeployments = Deployment.query.order_by(Deployment.user_id.desc()).all()
alldomains = Domain.query.order_by(Domain.user_id.desc()).all()
alldeployments = Deployment.query.order_by(Deployment.date_last_charge.asc()).all()
alldomains = Domain.query.order_by(Domain.date_expire.asc()).all()
allservices = Service.query.order_by(Service.date_last_charge.asc()).all()
alladdresses = Address.query.order_by(Address.user_id.asc()).all()
return render_template('admin/list_items.html', deployments=alldeployments, domains=alldomains, services=allservices, addresses=alladdresses)
@ -124,7 +124,6 @@ def dashboard(user_pid=0):
flash('Deploy #{} unreachable. Support is notified'.format(str(cubeid)))
send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(cubeid),
'vmanager/email/adm_unreachable', user=cuser, cubeid=cubeid )
current_app.logger.info('[{}] deployments: {}, services: {}, domains: {}, services: {}'.format(cuser.email, inv_deploynames, inv_services, inv_domains, inv_addresses ))
return render_template('vmanager/dashboard.html', rrd=rrd, status=statuses, inv_deployments=deployments, inv_services=services, inv_domains=domains, inv_addresses=addresses)
@ -155,5 +154,5 @@ def transaction(user_pid=0):
translist.insert(0, 0)
#current_app.logger.info('[{}] transactions: {} {} '.format(cuser.email, translist, labelslist))
return render_template('uinvoice/transactions.html', transactions=transactions, translist=translist, labelslist=labelslist)
return render_template('uinvoice/transactions.html', transactions=transactions, translist=translist, labelslist=labelslist, cuser=cuser)

View file

@ -10,6 +10,20 @@ from .forms import LoginForm, TwoFAForm, RegistrationForm, ChangePasswordForm,Pa
from io import BytesIO
import pyqrcode
def get_google_auth(state=None, token=None):
if token:
return OAuth2Session(current_app.config['CLIENT_ID'], token=token)
if state:
return OAuth2Session(
current_app.config['CLIENT_ID'],
state=state,
redirect_uri=current_app.config['REDIRECT_URI'])
oauth = OAuth2Session(
current_app.config['CLIENT_ID'],
redirect_uri=current_app.config['REDIRECT_URI'],
scope=current_app.config['SCOPE'])
return oauth
@auth.before_app_request
def before_request():
#print('session: %s' % str(session))
@ -27,7 +41,6 @@ def unconfirmed():
return redirect(url_for('main.index'))
return render_template('auth/unconfirmed.html')
@auth.route('/login', methods=['GET', 'POST'])
def login():
page = { 'title': 'Login' }
@ -71,10 +84,8 @@ def twofactor():
abort(404)
if 'memberberry' not in session:
abort(404)
page = { 'title': '2-Factor Login' }
form = TwoFAForm()
if form.validate_on_submit():
user = User.query.filter_by(email=session['email']).first()
del session['email']
@ -97,8 +108,6 @@ def twofactor():
flash('Invalid token.')
return render_template('auth/2fa.html', page=page, form=form)
@auth.route('/qrcode')
@login_required
def qrcode():
@ -121,7 +130,6 @@ def qrcode():
'Pragma': 'no-cache',
'Expires': '0'}
@auth.route("/logout", methods=['GET'])
@login_required
def logout():
@ -129,7 +137,6 @@ def logout():
flash('You have logged out')
return redirect(url_for('main.index'))
@auth.route('/register', methods=['GET', 'POST'])
def register():
#print(current_app.secret_key)
@ -139,14 +146,11 @@ def register():
user = User(email=form.email.data, password=form.password.data, wallet=current_app.config['REGISTER_BONUS'])
db.session.add(user)
db.session.commit()
transaction = Transaction(user_id=int(user.pid), description='Registered account bonus', value=current_app.config['REGISTER_BONUS'])
db.session.add(transaction)
db.session.commit()
token = user.generate_confirmation_token()
send_email(user.email, 'Потвърдетеашият_акаунт', 'auth/email/confirm', user=user, token=token)
#notify admin
newip = request.remote_addr
if request.headers.getlist("X-Forwarded-For"):
@ -158,7 +162,6 @@ def register():
return redirect(url_for('auth.login'))
return render_template('auth/register.html', page=page, form=form)
@auth.route('/confirm/<token>')
@login_required
def confirm(token):
@ -170,7 +173,6 @@ def confirm(token):
flash('Времето за потвърждение на вашият код изтече.')
return redirect(url_for('main.index'))
@auth.route('/confirm')
@login_required
def resend_confirmation():
@ -180,7 +182,6 @@ def resend_confirmation():
flash('Изпратен е нов код за потвърждение..')
return redirect(url_for('main.index'))
@auth.route('/change-password', methods=['GET', 'POST'])
@login_required
def change_password():
@ -196,7 +197,6 @@ def change_password():
flash('Грешна парола.')
return render_template("auth/change_password.html", form=form)
@auth.route('/reset', methods=['GET', 'POST'])
def password_reset_request():
if not current_user.is_anonymous:
@ -215,7 +215,6 @@ def password_reset_request():
return redirect(url_for('auth.login'))
return render_template('auth/reset_password.html', form=form)
@auth.route('/reset/<token>', methods=['GET', 'POST'])
def password_reset(token):
if not current_user.is_anonymous:
@ -232,4 +231,3 @@ def password_reset(token):
return redirect(url_for('main.index'))
return render_template('auth/reset_password.html', form=form)

View file

@ -55,6 +55,7 @@ class User(db.Model, UserMixin):
email = db.Column(db.String(64), unique=True, index=True)
role_id = db.Column(db.Integer, db.ForeignKey('roles.pid')) #FK
password_hash = db.Column(db.String(128))
tokens = db.Column(db.Text)
confirmed = db.Column(db.Boolean, default=False)
active = db.Column(db.Boolean, default=True)
@ -75,8 +76,6 @@ class User(db.Model, UserMixin):
org_companyname = db.Column(db.Unicode(64))
org_regaddress = db.Column(db.Unicode(128))
org_responsible = db.Column(db.Unicode(128))
org_bulstat = db.Column(db.String(16))
org_vat = db.Column(db.Boolean, default=False)
org_vatnum = db.Column(db.String(16))
group = db.Column(db.String(24), default='User')
@ -245,7 +244,7 @@ class Deployment(db.Model):
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, index=True, default=datetime.utcnow)
date_last_charge = db.Column(db.DateTime)
enabled = db.Column(db.Boolean)
enabled = db.Column(db.Boolean, default=False)
machine_id = db.Column(db.BigInteger) #cubeid
machine_alias = db.Column(db.String) #dns name

View file

@ -9,25 +9,23 @@ from wtforms import validators, ValidationError
from wtforms.fields.html5 import EmailField
class EditProfileForm(FlaskForm):
name = StringField('Лице за контакт:', [validators.DataRequired(), validators.Length(3, 60)])
address = StringField('Адрес:', [validators.DataRequired(), validators.Length(2, 50)])
city = StringField('Град:', [validators.DataRequired(), validators.Length(2,40)])
name = StringField('Name:', [validators.DataRequired(), validators.Length(3, 60)])
address = StringField('Address:', [validators.DataRequired(), validators.Length(2, 50)])
city = StringField('City:', [validators.DataRequired(), validators.Length(2,40)])
postcode = StringField('Пощенски Код:')
postcode = StringField('Postcode:')
clist = []
for c in countries:
clist.append((c.alpha2, c.name))
country = SelectField('Държава:', choices=clist, default='BG')
country = SelectField('Country:', choices=clist, default='BG')
phone = StringField('Телефон:')
org_account = BooleanField('Юридическо лице')
org_companyname = StringField('Име на фирма:')
org_regaddress = StringField('Адресна регистрация:')
org_responsible = StringField('Отговорно Лице:')
org_bulstat = StringField('БУЛСТАТ:')
org_vat = BooleanField('Регистрация по ДДС')
org_vatnum = StringField('ДДС Номер:')
phone = StringField('Phone:')
org_account = BooleanField('This is a business account.')
org_companyname = StringField('Company Name:')
org_regaddress = StringField('Company Address:')
org_responsible = StringField('Accountable Person (optional):')
org_vatnum = StringField('VAT Number:')
twofactor = BooleanField('2-factor authentication')
submit = SubmitField('Обнови')
@ -48,12 +46,10 @@ class EditProfileAdminForm(FlaskForm):
country = SelectField('Държава:', choices=clist)
phone = DecimalField('Телефон:', [validators.DataRequired()])
org_account = BooleanField('Юридическо лице')
org_companyname = StringField('Име на фирма:')
org_regaddress = StringField('Адресна регистрация:')
org_responsible = StringField('Отговорно Лице:')
org_bulstat = StringField('БУЛСТАТ:')
org_vat = BooleanField('Регистрация по ДДС')
org_account = BooleanField('This is a business account')
org_companyname = StringField('Company Name:')
org_regaddress = StringField('Company Address:')
org_responsible = StringField('Primary Contact:')
org_vatnum = StringField('ДДС Номер:')
twofactor = BooleanField('2-factor authentication')
submit = SubmitField('Обнови')

View file

@ -27,8 +27,6 @@ def profile():
current_user.org_companyname = form.org_companyname.data
current_user.org_regaddress = form.org_regaddress.data
current_user.org_responsible = form.org_responsible.data
current_user.org_bulstat = form.org_bulstat.data
current_user.org_vat = form.org_vat.data
current_user.org_vatnum = form.org_vatnum.data
current_user.twofactor = form.twofactor.data
db.session.add(current_user)
@ -45,13 +43,11 @@ def profile():
form.org_companyname.data = current_user.org_companyname
form.org_regaddress.data = current_user.org_regaddress
form.org_responsible.data = current_user.org_responsible
form.org_bulstat.data = current_user.org_bulstat
form.org_vat.data = current_user.org_vat
form.org_vatnum.data = current_user.org_vatnum
form.twofactor.data = current_user.twofactor
wallet = "%.2f" % round(current_user.wallet, 3)
#current_app.logger.info('[{}] wallet: {}'.format(current_user.email, wallet))
return render_template('settings/profile.html', page=page, form=form, wallet=wallet)
return render_template('settings/profile.html', page=page, form=form, wallet=wallet, cuser=current_user)

View file

@ -5,7 +5,7 @@ body {
-moz-background-size: cover;
-o-background-size: cover;
padding-top: 0px;
background-color: #cccccc;
background-color: #edf0f5;
background-repeat: no-repeat;
background-attachment: fixed;
top:0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -21,7 +21,9 @@
<th>CPU</th>
<th>Mem</th>
<th>HDD</th>
<th>Price per month</th>
<th>Owner</th>
<th>Last Charged</th>
</tr>
</thead>
<tbody>
@ -29,10 +31,12 @@
<tr>
<td>{% if deploy.enabled == True %}<font color="green">{% else %}<font color="red">{% endif %}{{ deploy.machine_id }}</td>
<td>{{ deploy.machine_alias }}</font></td>
<td>{{ deploy.machine_cpu }} Cores</td>
<td>{{ deploy.machine_cpu }} c.</td>
<td>{{ deploy.machine_mem }} MB</td>
<td>{{ deploy.machine_hdd }} GB</td>
<td>{{ deploy.price }} </td>
<td><a href="{{ url_for('admin.dashboard', user_pid=deploy.user_id) }}">{{ deploy.owner.email }}</a></td>
<td>{{ moment(deploy.date_last_charge).format('lll') }} ({{ moment(deploy.date_last_charge).fromNow() }})</td>
{% endfor %}
</tbody>
</table>
@ -49,10 +53,10 @@
<tr>
<th>Category</th>
<th>Description</th>
<th>Months</th>
<th>Price</th>
<th>Period (Months)</th>
<th>Last Charged</th>
<th>Owner</th>
<th>Last Charged</th>
</tr>
</thead>
<tbody>
@ -60,10 +64,10 @@
<tr>
<td>{{ service.category }}</td>
<td>{{ service.description }}</td>
<td>{{ service.price }}</td>
<td>{{ service.period }}</td>
<td>{{ moment(service.date_last_charge).format('lll') }}</td>
<td>{{ service.price }}</td>
<td><a href="{{ url_for('admin.dashboard', user_pid=service.user_id) }}">{{ service.owner.email }}</a></td>
<td>{{ moment(service.date_last_charge).format('ll') }} ({{ moment(service.date_last_charge).fromNow() }})</td>
</tr>
{% endfor %}
</tbody>

View file

@ -25,7 +25,7 @@
<td>{{ usr.pid }}</td>
<td>{{ usr.email }}</td>
<td>{{ moment(usr.last_seen).format('lll') }}</td>
<td>{{ usr.last_ip }}</td>
<td><a href="https://apps.db.ripe.net/search/query.html?searchtext={{ usr.last_ip }}" data-toggle="tooltip" title="RIPE Whois Search" target="_blank">{{ usr.last_ip }}</a></td>
<td>{{ usr.wallet }}<td>
<td><a href="{{ url_for('admin.charge', user_pid=usr.pid) }}" data-toggle="tooltip" title="Add Funds"><span class="glyphicon glyphicon-plus"></span></a>
<a href="{{ url_for('admin.transaction', user_pid=usr.pid) }}" data-toggle="tooltip" title="List Transactions"><span class="glyphicon glyphicon-credit-card"></span></a>

View file

@ -44,7 +44,7 @@
</div>
{% block footer %}
{% include "footer_simple.html" %}
{% include "main/footer_simple.html" %}
{% endblock %}
{% endblock %}

View file

@ -1,8 +0,0 @@
<div id="footer_copyright">
<div class="page_wrap">
<p class="copyright">&copy; Copyright 2017 <a href="https://deflax.net">_sys</a>, All Rights Reserved.</p>
<p class="design_by">eof</p>
</div><!--/page wrap-->
</div><!--/footer copyright-->

View file

@ -0,0 +1,8 @@
<div id="footer_copyright">
<div class="page_wrap">
<p class="copyright"><a href="{{ url_for('main.terms') }}">Terms of Service</a> &copy; Copyright 2017 <a href="https://deflax.net">_sys</a>, All Rights Reserved.</p>
<p class="design_by"></p>
</div><!--/page wrap-->
</div><!--/footer copyright-->

View file

@ -93,7 +93,7 @@
<div class="panel-body">
<img src="../../static/images/VPS-Mission.png" width="128" height="128" />
<h2 class="media-heading">Мисия</h2>
<p>Основната ни цел е безкомпромисно качество на услугите ни. Предлагаме цялостна поддръжка на вашите машини, включително тези които използвате във Вашият офис.</p>
<p>Основната ни цел е безкомпромисно качество на услугите. Предлагаме цялостна поддръжка на вашите машини, включително тези които използвате във Вашият офис.</p>
</div>
</div>
@ -111,6 +111,6 @@
{% endblock %}
{% block footer %}
{% include "footer_index.html" %}
{% include "footer_colored.html" %}
{% include "main/footer_index.html" %}
{% include "main/footer_colored.html" %}
{% endblock %}

View file

@ -44,7 +44,7 @@
<li><a href="{{ url_for('auth.login') }}"><span class="glyphicon glyphicon-lock"></span> Login</a></li>
{% else %}
{% if current_user.is_administrator() %}
<li><a href="{{ url_for('admin.list_items') }}"><span class="glyphicon glyphicon-wrench"></span> Admin Panel</a></li>
<li><a href="{{ url_for('admin.index') }}"><span class="glyphicon glyphicon-wrench"></span> Admin Panel</a></li>
{% endif %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img class="avatar" src="{{ current_user.gravatar(20) }}"> {{ current_user.email }} <span class="caret"></span></a>

View file

@ -1,10 +1,11 @@
<div class="panel panel-info">
<div class="panel-heading">{{ current_user.name }}</div>
<div class="panel-heading">{{ cuser.name }}</div>
<div class="panel-body">
<a href="https://en.gravatar.com/site/signup/"><img class="roundavatar" align="right" src="{{ current_user.gravatar(128) }}"></img></a>
<a href="https://en.gravatar.com/site/signup/"><img class="roundavatar" align="right" src="{{ cuser.gravatar(128) }}"></img></a>
<p><br />
<b>Wallet:</b> {{ current_user.wallet|round(2) }}<br />
<b>Currenty:</b> {{ current_user.currency }}<br />
<b>Currency:</b> {{ cuser.currency }}<br />
<b>Wallet:</b> {{ cuser.wallet|round(2) }}<br />
<b>Overdraft:</b> {{ cuser.overdraft }}<br />
</p>
</div>
</div>

View file

@ -115,15 +115,6 @@ $("#{{ form.org_account.id }}").click(function() {
{{ error }}<br />
{% endfor %}
</p>
<p>
{{ form.org_bulstat.label }}<br />{{ form.org_bulstat }}<br />
{% for error in form.org_bulstat.errors %}
{{ error }}<br />
{% endfor %}
</p>
<p>
{{ form.org_vat }} {{ form.org_vat.label }}
</p>
<p>
{{ form.org_vatnum.label }}<br />{{ form.org_vatnum }}<br />
{% for error in form.org_vatnum.errors %}

View file

@ -38,14 +38,32 @@ var myChart = new Chart(ctx, {
{% endblock %}
{% block page_content %}
<div class="row">
{% block sidebar %}
<div class="col-md-12">
<div class="row">
</div>
</div>
{% endblock %}
<div class="row">
<div class="col-md-4">
{% include "/settings/acc_avatar.html" %}
</div>
<div class="col-md-8">
<div class="panel panel-info">
<div class="panel-heading">Wallet Graph</div>
<div class="panel-body">
<canvas id="transchart" height="80"></canvas>
</div></div></div>
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading">Transactions</div>
<div class="panel-body">
<canvas id="transchart" height="80"></canvas>
<div class="table-responsive">
<table class="table table-hover table-striped table-condensed cf">
<thead>

View file

@ -14,7 +14,7 @@ from ..models import User, Transaction
def transactions():
page = { 'title': 'Payment Transaction' }
cuser = current_user
transactions = Transaction.query.filter_by(user_id=cuser.pid).order_by(Transaction.date_created.asc()).limit(100)
transactions = Transaction.query.filter_by(user_id=cuser.pid).order_by(Transaction.date_created.desc()).limit(100)
labelslist = ['today']
translist = [cuser.wallet]
@ -29,7 +29,7 @@ def transactions():
translist.insert(0, 0)
#current_app.logger.info('[{}] transactions: {} {} '.format(cuser.email, translist, labelslist))
return render_template('uinvoice/transactions.html', transactions=transactions, translist=translist, labelslist=labelslist)
return render_template('uinvoice/transactions.html', transactions=transactions, translist=translist, labelslist=labelslist, cuser=cuser)
@uinvoice.route('/order/<int:document_id>', methods=['GET', 'POST'])
@login_required