various fixes

This commit is contained in:
deflax 2017-10-07 18:39:50 +03:00
parent 96e62c8c4f
commit 2399334a18
17 changed files with 295 additions and 115 deletions

View file

@ -114,6 +114,15 @@ def internal_server_error(e):
return response
return render_template('errors/500.html'), 500
@app.errorhandler(503)
def service_unavailable(e):
if request.accept_mimetypes.accept_json and \
not request.accept_mimetypes.accept_html:
response = jsonify({'error': 'service unavailable'})
response.status_code = 503
return response
return render_template('errors/503.html'), 503
@app.errorhandler(CSRFError)
def handle_csrf_error(e):
return render_template('errors/csrf_error.html', reason=e.description), 400

View file

@ -39,21 +39,21 @@ def index():
@login_required
@admin_required
def list_deployments():
alldeployments = Deployment.query.filter_by(cancelled=False).order_by(Deployment.daysleft.asc()).all()
alldeployments = Deployment.query.filter_by(deleted=False).order_by(Deployment.daysleft.asc()).all()
return render_template('admin/list_deployments.html', deployments=alldeployments)
@admin.route("/listservices", methods=['GET'])
@login_required
@admin_required
def list_services():
allservices = Service.query.filter_by(cancelled=False).order_by(Service.daysleft.asc()).all()
allservices = Service.query.filter_by(deleted=False).order_by(Service.daysleft.asc()).all()
return render_template('admin/list_services.html', services=allservices)
@admin.route("/listdomains", methods=['GET'])
@login_required
@admin_required
def list_domains():
alldomains = Domain.query.filter_by(cancelled=False).order_by(Domain.daysleft.asc()).all()
alldomains = Domain.query.filter_by(deleted=False).order_by(Domain.daysleft.asc()).all()
return render_template('admin/list_domains.html', domains=alldomains)
@admin.route("/listrecyclebin", methods=['GET'])
@ -61,8 +61,8 @@ def list_domains():
@admin_required
def list_recyclebin():
deployments = Deployment.query.filter_by(protected=False).order_by(Deployment.daysleft.asc()).all()
services = Service.query.filter_by(cancelled=True).all()
domains = Domain.query.filter_by(cancelled=True).all()
services = Service.query.filter_by(deleted=True).all()
domains = Domain.query.filter_by(deleted=True).all()
return render_template('admin/list_recyclebin.html', deployments=deployments, services=services, domains=domains)
@admin.route("/listaddresses", methods=['GET'])
@ -152,7 +152,7 @@ def transaction(user_pid=0):
def dashboard(user_pid=0):
cuser = User.query.filter_by(pid=user_pid).first()
inv_deployments = cuser.inv_deployments.filter_by(cancelled=False).order_by(Deployment.date_created.desc()).all()
inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all()
inv_deploycubeids = []
inv_deployments_list = []
for invcls in inv_deployments:
@ -160,13 +160,13 @@ def dashboard(user_pid=0):
inv_deploycubeids.extend([invcls.machine_id])
inv_deployments_list.extend([invcls.machine_alias])
inv_services = cuser.inv_services.filter_by(cancelled=False).order_by(Service.date_last_charge.asc()).all()
inv_services = cuser.inv_services.filter_by(deleted=False).order_by(Service.date_last_charge.asc()).all()
inv_services_list = []
for invcls in inv_services:
if invcls.user_id == cuser.pid:
inv_services_list.extend([invcls.description])
inv_domains = cuser.inv_domains.filter_by(cancelled=False).order_by(Domain.date_created.desc()).all()
inv_domains = cuser.inv_domains.filter_by(deleted=False).order_by(Domain.date_created.desc()).all()
inv_domains_list = []
for invcls in inv_domains:
if invcls.user_id == cuser.pid:
@ -205,7 +205,7 @@ 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.warning('[ADMIN] {} deployments: {}, services: {}, domains: {}, services: {}'.format(cuser.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_addresses_list ))
#current_app.logger.warning('[ADMIN] {} deployments: {}, services: {}, domains: {}, services: {}'.format(cuser.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_addresses_list ))
return render_template('main/dashboard.html', rrd=rrd, status=statuses, inv_deployments=inv_deployments, inv_services=inv_services, inv_domains=inv_domains, inv_addresses=inv_addresses, region=regions)

View file

@ -33,13 +33,33 @@ def chat():
def terms():
return render_template('main/terms.html')
#APP STORE
@main.route('/market/<int:group_id>', methods=['GET'])
@login_required
def market(group_id=0):
page = { 'title': 'Market' }
allproducts = Product.get_products()
allgroups = current_app.config['GROUPS']
if group_id == 0:
return render_template('main/market.html', groups=allgroups, products=allproducts)
filtered_products = {}
for key, value in allproducts.items():
if value['group'] == group_id:
filtered_products[key] = value
if filtered_products == {}:
abort(404)
return render_template('main/marketgroup.html', groupname=allgroups[group_id], products=filtered_products)
#DASHBOARD
@main.route("/dashboard", methods=['GET', 'POST'])
@login_required
def dashboard():
cuser = current_user
inv_deployments = cuser.inv_deployments.filter_by(cancelled=False).order_by(Deployment.date_created.desc()).all()
inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all()
inv_deploycubeids = []
inv_deployments_list = []
for invcls in inv_deployments:
@ -47,13 +67,13 @@ def dashboard():
inv_deploycubeids.extend([invcls.machine_id])
inv_deployments_list.extend([invcls.machine_alias])
inv_services = cuser.inv_services.filter_by(cancelled=False).order_by(Service.date_last_charge.asc()).all()
inv_services = cuser.inv_services.filter_by(deleted=False).order_by(Service.date_last_charge.asc()).all()
inv_services_list = []
for invcls in inv_services:
if invcls.user_id == cuser.pid:
inv_services_list.extend([invcls.description])
inv_domains = cuser.inv_domains.filter_by(cancelled=False).order_by(Domain.date_created.desc()).all()
inv_domains = cuser.inv_domains.filter_by(deleted=False).order_by(Domain.date_created.desc()).all()
inv_domains_list = []
for invcls in inv_domains:
if invcls.user_id == cuser.pid:
@ -99,6 +119,6 @@ def dashboard():
send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(cubeid),
'vmanager/email/adm_unreachable', user=current_user, cubeid=cubeid )
#current_app.logger.info('[{}] Enabled deployments: {}, services: {}, domains: {}, addresses: {}'.format(current_user.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_addresses_list ))
current_app.logger.info('[{}] Enabled deployments: {}, services: {}, domains: {}, addresses: {}'.format(current_user.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_addresses_list ))
return render_template('main/dashboard.html', rrd=rrd, status=statuses, inv_deployments=inv_deployments, inv_services=inv_services, inv_domains=inv_domains, inv_addresses=inv_addresses, region=regions)

View file

@ -86,10 +86,12 @@ class User(db.Model, UserMixin):
currency = db.Column(db.String, default='BGN')
inv_routers = db.relationship('Router', backref='owner', lazy='dynamic')
inv_addresses = db.relationship('Address', backref='owner', lazy='dynamic')
inv_bridges = db.relationship('Bridge', backref='owner', lazy='dynamic')
inv_deployments = db.relationship('Deployment', backref='owner', lazy='dynamic')
inv_services = db.relationship('Service', backref='owner', lazy='dynamic')
inv_domains = db.relationship('Domain', backref='owner', lazy='dynamic')
inv_addresses = db.relationship('Address', backref='owner', lazy='dynamic')
inv_transactions = db.relationship('Transaction', backref='owner', lazy='dynamic')
@ -233,42 +235,53 @@ class Router(db.Model):
__tablename__ = 'routers'
pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, index=True, default=datetime.utcnow)
cancelled = db.Column(db.Boolean, default=False)
date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False)
machine_id = db.Column(db.BigInteger) #cubeid
class Bridge(db.Model):
__tablename__ = 'bridge'
pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False)
bridge_id = db.Column(db.String)
class Deployment(db.Model):
__tablename__ = 'deployments'
pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, index=True, default=datetime.utcnow)
date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False)
enabled = db.Column(db.Boolean, default=True)
warning = db.Column(db.Boolean, default=False)
protected = db.Column(db.Boolean, default=False) #machines with this False will be autodeleted after the warning period is over.
date_last_charge = db.Column(db.DateTime)
period = db.Column(db.Integer)
daysleft = db.Column(db.Integer)
warning = db.Column(db.Boolean, default=False)
enabled = db.Column(db.Boolean, default=True)
cancelled = db.Column(db.Boolean, default=False)
protected = db.Column(db.Boolean, default=False) #machines with this False will be autodeleted after the warning period is over.
machine_id = db.Column(db.BigInteger) #cubeid
machine_alias = db.Column(db.String) #dns name
machine_cpu = db.Column(db.Integer)
machine_mem = db.Column(db.Integer)
machine_hdd = db.Column(db.Integer)
machine_addresses = db.relationship('Address', backref='deployments', lazy='dynamic')
discount = db.Column(db.Integer)
class Service(db.Model):
__tablename__ = 'services'
pid = db.Column(db.Integer, primary_key=True) #PK
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, index=True, default=datetime.utcnow)
date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False)
enabled = db.Column(db.Boolean, default=False)
warning = db.Column(db.Boolean, default=False)
date_last_charge = db.Column(db.DateTime)
period = db.Column(db.Integer)
daysleft = db.Column(db.Integer)
warning = db.Column(db.Boolean, default=False)
enabled = db.Column(db.Boolean, default=False)
cancelled = db.Column(db.Boolean, default=False)
category = db.Column(db.String)
description = db.Column(db.Unicode)
@ -286,12 +299,12 @@ class Region(db.Model):
class Address(db.Model):
__tablename__ = 'address'
pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_assigned = db.Column(db.DateTime, default=datetime.utcnow)
enabled = db.Column(db.Boolean)
date_assigned = db.Column(db.DateTime, index=True, default=datetime.utcnow)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
region_id = db.Column(db.Integer, db.ForeignKey('regions.pid')) #FK
deploy_id = db.Column(db.Integer, db.ForeignKey('deployments.pid')) #FK
router_id = db.Column(db.Integer, db.ForeignKey('routers.pid')) #FK
ip = db.Column(db.String)
mac = db.Column(db.String)
@ -322,14 +335,15 @@ class Address(db.Model):
class Domain(db.Model):
__tablename__ = 'domains'
pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False)
date_expire = db.Column(db.DateTime)
daysleft = db.Column(db.Integer)
warning = db.Column(db.Boolean, default=False)
enabled = db.Column(db.Boolean, default=False)
cancelled = db.Column(db.Boolean, default=False)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, index=True, default=datetime.utcnow)
date_expire = db.Column(db.DateTime)
fqdn = db.Column(db.String, unique=True)
auto_update = db.Column(db.Boolean)
@ -338,7 +352,8 @@ class Transaction(db.Model):
__tablename__ = 'transaction'
pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, index=True, default=datetime.utcnow)
date_created = db.Column(db.DateTime, default=datetime.utcnow)
currency = db.Column(db.String, default='BGN')
description = db.Column(db.String)
value = db.Column(db.Float)
@ -346,9 +361,10 @@ class Transaction(db.Model):
class Invoice(db.Model):
__tablename__ = 'invoice'
pid = db.Column(db.Integer, primary_key=True)
invoice_number = db.Column(db.Integer, unique=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, index=True, default=datetime.utcnow)
date_created = db.Column(db.DateTime, default=datetime.utcnow)
invoice_number = db.Column(db.Integer, unique=True)
currency = db.Column(db.String, default='BGN')
tax = db.Column(db.Float) #VAT
description = db.Column(db.Unicode)

View file

@ -6,13 +6,13 @@ import requests
import json
from facepy import GraphAPI
@lru_cache(maxsize=8)
@lru_cache(maxsize=32)
def get_fb_token():
payload = {'grant_type': 'client_credentials', 'client_id': current_app.config['FB_APP_ID'], 'client_secret': current_app.config['FB_APP_SECRET']}
response = requests.post('https://graph.facebook.com/oauth/access_token?', params = payload)
fbjson = json.loads(response.text)
fbtoken = fbjson['access_token']
current_app.logger.info("FB Token: {}".format(fbtoken))
#current_app.logger.info("FB Token: {}".format(fbtoken))
return fbtoken
@news.route("/all", methods=['GET'])

View file

@ -74,7 +74,7 @@ addEventListener("DOMContentLoaded", function() {
</thead>
<tbody>
{% for deploy in deployments %}
{% if deploy.cancelled == True %}
{% if deploy.deleted == True %}
<tr class="active">
{% else %}
{% if deploy.enabled == False %}
@ -99,7 +99,7 @@ addEventListener("DOMContentLoaded", function() {
<td>{{ moment(deploy.date_last_charge).format('lll') }} ({{ moment(deploy.date_last_charge).fromNow() }})</td>
{% endif %}
<td>{{ deploy.daysleft }}</td>
{% if deploy.cancelled == True %}
{% if deploy.deleted == True %}
<td>-deleted-</td>
{% else %}
<td><button class="btn btn-default btn-danger" onclick="location.reload();location.href='/vmanager/vmremove/{{ deploy.machine_id }}'"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete</button></td>

View file

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block title %}Forbidden{% endblock %}
{% block page_content %}
<div class="page-header">
<h1>Forbidden</h1>
</div>
<b>
<pre>
,-.
/ \ `. __..-,O
: \ --''_..-'.'
| . .-' `. '.
: . .`.'
\ `. / ..
\ `. ' .
`, `. \
,|,`. `-.\
'.|| ``-...__..-`
| |
|__|
/||\
//||\\
// || \\
__//__||__\\__
'--------------' SSt
</pre>
</b>

View file

@ -1,5 +1,30 @@
{% extends "base.html" %}
{% block styles %}
{{ super() }}
<link href="/static/css/simple-slideshow-styles.css" type="text/css" rel="stylesheet" media="screen">
<style>
body {
background-image: url('/static/images/cloudsbg.jpeg');
}
.panel-transparent {
background: none;
}
.panel-transparent .panel-heading {
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
.panel-transparent .panel-body{
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
</style>
{% endblock %}
{% block page_content %}
<h1>About us</h1>
<center>
@ -7,6 +32,27 @@
<img src="../../static/images/datapoint.png" class="img-responsive"></img>
</div>
<pre>
,-.
/ \ `. __..-,O
: \ --''_..-'.'
| . .-' `. '.
: . .`.'
\ `. / ..
\ `. ' .
`, `. \
,|,`. `-.\
'.|| ``-...__..-`
| |
|__|
/||\
//||\\
// || \\
__//__||__\\__
'--------------' SSt
</pre>
<p style="text-align: left;"> datapoint.bg е проект на Новахостинг ЕООД който създадохме, за да предоставим на потребителите ново поколение изчислителни услуги. Стремим се да помагаме на неуверените и неопитни потребители в първата им среща с тях, като сме на линия за съвети отновно одимите услуги и инструменти, за да не влагате излишни средства в ресурси.</p>
<h3 style="text-align: left;"> Историята</h3>
<p style="text-align: left;"> Този сайт е естествено продължение на няколко лични проекта на двама ентусиасти, на едно пространство, използвано по много предназначения и наричано от нас просто “избата“. Там е мястото, където се затваряхме, за да свършим малко работа бързо и без никой да знае къде сме. От там са тръгнали много идеи, за да оживеят в сървърното помещение, което изградихме първоначално за собствена употреба. После пораснахме и дойдоха идеите, а след тях и клиентите ни. Както споменах естественото продължение на нещата беше да затворим цялостно процеса на работа и усъвършенствахме сървърното помещение, за да е пригодно за крайни клиенти. Докато се усетим имахме готово чисто ново сървърно помещение- мечта за всеки системен администратор. С мощни сървъри, гъвкава мрежова инфраструктура, резервирана свързаност с най- големите български интернет доставчици, резервирано захранване, климатични системи, температурен контрол, цялостен мониторинг и ново поколение охранителна система.</p>

View file

@ -2,6 +2,22 @@
{% block styles %}
{{ super() }}
<style type="text/css">
.panel-transparent {
background: none;
}
.panel-transparent .panel-heading {
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
.panel-transparent .panel-body{
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
</style>
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:1px 1px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
@ -125,7 +141,7 @@ addEventListener("DOMContentLoaded", function() {
<div class="col-md-12">
<div class="panel panel-info" id="deployments">
<div class="panel-heading">Deployments</div>
<div class="panel-heading">Device Manager</div>
<div class="panel-body"><p>
{% if inv_deployments != [] %}
@ -286,7 +302,7 @@ addEventListener("DOMContentLoaded", function() {
{% if inv_addresses != [] %}
<div class="col-md-12">
<div class="panel panel-info" id="addresses">
<div class="panel-heading">Addresses</div>
<div class="panel-heading">Communications</div>
<div class="panel-body"><p>
<div id="no-more-tables">
<table class="table table-hover table-striped table-condensed cf">

View file

@ -46,7 +46,12 @@
<script type="text/javascript">
$(document).ready(function() {
$('#newsmenu').load('https://www.datapoint.bg/news/latest');
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$('#livesupport').load('https://www.datapoint.bg/kiwi/');
});
</script>
{% endblock %}
@ -75,6 +80,8 @@
</div>
</div>
<div class="container-fluid-index">
<div class="row">
<div class="col-md-6">
@ -82,15 +89,16 @@
<div class="panel-body">
<img src="../../static/images/VPS-equipment.png" width="128" height="128" />
<h2 class="media-heading">Оборудване</h2>
<p>Благодарение на внедрените нови технологии ние предлагаме изчислителна мощ, надеждно съхранение на данни и гъвкаво разпределение на ресурсите.</p>
<p>Благодарение на внедрените нови технологии ние предлагаме изчислителна мощ, надеждно съхранение на данни и гъвкаво разпределение на ресурсите. Предвиждаме възможности нашата система да бъде неразделна част от текущата ви инфраструктура.</p>
</div>
</div>
<div class="panel panel-primary panel-transparent">
<div class="panel-body">
<img src="../../static/images/VPS-Support.png" width="128" height="128" />
<h2 class="media-heading">Бърз приятелски support</h2>
<h2 class="media-heading">Поддръжка</h2>
<p>Ще Ви помогнем във всички неприятни ситуации, по всяко време. Независимо от нивото на умения Ви. Ние сме винаги насреща за въпроси.</p>
<a href="/chat"><button type="button" class="btn btn-success">Support</button></a>
</div>
</div>
</div>
@ -100,7 +108,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>
@ -109,12 +117,23 @@
<div class="panel-body">
<img src="../../static/images/VPS-Security.png" width="128" height="128" />
<h2 class="media-heading">Сигурност и надеждност</h2>
<p>Разработваме система за контрол и наблюдение на Вашите изчислителни процеси в реално време, обезпечена от най-големите български доставчици на интернет свързаност.</p>
<p>Системата включва контрол и наблюдение на Вашите процеси в реално време и е обезпечена от най-големите български доставчици на интернет свързаност.</p>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary panel-transparent">
<div class="panel-body">
<!--iframe src="https://datapoint.bg/kiwi/" style="border:0; width:100%; height:480px;"></iframe>-->
</div>
</div>
</div>
</div>
{% endblock %}
{% block footer %}

View file

@ -1,11 +1,43 @@
{% extends "base.html" %}
{% block styles %}
{{ super() }}
<style>
body {
background-image: url('/static/images/cloudsbg.jpeg');
}
.panel-transparent {
background: none;
}
.panel-transparent .panel-heading {
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
.panel-transparent .panel-body{
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
</style>
{% endblock %}
{% block page_content %}
<iframe src="https://kiwiirc.com/client/irc.datapoint.bg:+6697/?&theme=relaxed#support" style="border:0; width:100%; height:640px;"></iframe>
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary panel-transparent">
<div class="panel-body">
<iframe src="https://datapoint.bg/kiwi/" style="border:0; width:100%; height:460px;"></iframe>
To permanently stay connected to our chat network you could use an client like <a href="https://hexchat.github.io/downloads.html">HexChat</a> and use the following URL:<br /><a href="irc://irc.datapoint.bg:+6697/#support">irc://irc.datapoint.bg:+6697/#support</a>
</div>
</div>
</div>
</div>
{% endblock %}
To permanently stay connected to our chat network you could use an client like <a href="https://hexchat.github.io/downloads.html">HexChan</a> and use the following URL <a href="irc://irc.datapoint.bg:+6697/#support">irc://irc.datapoint.bg:+6697/#support</a>
{% block footer %}
{% endblock %}

View file

@ -1,5 +1,30 @@
{% extends "base.html" %}
{% block styles %}
{{ super() }}
<link href="/static/css/simple-slideshow-styles.css" type="text/css" rel="stylesheet" media="screen">
<style>
body {
background-image: url('/static/images/cloudsbg.jpeg');
}
.panel-transparent {
background: none;
}
.panel-transparent .panel-heading {
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
.panel-transparent .panel-body{
background: rgb(255, 255, 255); /* fallback */
background: rgba(255, 255, 255, 0.7)!important;
}
</style>
{% endblock %}
{% block page_content %}
<div class="row">

View file

@ -35,8 +35,9 @@
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">Настройки</div>
<div class="panel-heading">Create Deployment</div>
<div class="panel-body">
<form method="POST" action="{{ url_for('vmanager.createvm') }}">
<p>
{{ form.servername.label }}<br />{{ form.servername(size=42) }}<br />

View file

@ -6,7 +6,7 @@ from . import vmanager
from .forms import CreateForm, ActivateForm
from .. import db
from ..email import send_email
from ..models import User, Permission, Transaction, Deployment, Service, Region, Address, Domain, contact_proxmaster
from ..models import User, Permission, Transaction, Router, Deployment, Service, Region, Address, Domain, contact_proxmaster
from ..decorators import admin_required, permission_required
import base64
@ -34,7 +34,7 @@ def createvm():
flash('Please update profile info for this operation.')
return redirect(url_for('settings.profile'))
deployment_seeds = current_user.inv_deployments.filter_by(cancelled=False).filter_by(protected=False).all()
deployment_seeds = current_user.inv_deployments.filter_by(deleted=False).filter_by(protected=False).all()
if deployment_seeds != []:
flash('Offline deployments still exist.')
return redirect(url_for('main.dashboard'))
@ -42,29 +42,6 @@ def createvm():
form = CreateForm()
if current_user.confirmed and form.validate_on_submit():
selected_region = Region.query.filter_by(pid=int(form.region.data)).first()
###
#flash('Region: {}'.format(str(selected_region.description)))
#return redirect(url_for('main.dashboard'))
router = current_user.inv_routers.filter_by(cancelled=False).all()
if router == []:
#no router. creating...
data = { 'clientid': str(current_user.pid),
'clientemail': str(current_user.email),
'hostname': 'c' + str(current_user.pid) + 'router',
'region': str(selected_region.name),
'type': 'kvm',
'cpu': '1',
'mem': '128',
'hdd': '1'
}
try:
query = contact_procmaster(data, 'vmcreate')
except:
flash('Region unreachable! Cannot create router. Please try again later...')
return redirect(url_for('main.dashboard'))
#exit 0
return redirect(url_for('main.dashboard'))
data = { 'clientid': str(current_user.pid),
'clientemail': str(current_user.email),
@ -85,9 +62,9 @@ def createvm():
deployment = Deployment(user_id=int(current_user.pid), machine_alias=query['hostname'], machine_id=query['cube'], machine_cpu=data['cpu'], machine_mem=data['mem'], machine_hdd=data['hdd'], enabled=True, protected=False, daysleft=15, warning=True, discount=0)
db.session.add(deployment)
db.session.commit()
flash('Deploy created successfully in region "{}".'.format(str(selected_region.description)))
flash('Machine created successfully in region "{}".'.format(str(selected_region.description)))
else:
flash('Deploy cancelled! Please try again later...')
flash('Machine creation cancelled! Please try again later...')
return redirect(url_for('main.dashboard'))
return render_template('vmanager/create.html', form=form)
@ -98,22 +75,27 @@ def remove(itemid=0):
data = {}
deploy = Deployment.query.filter_by(machine_id=int(itemid)).first()
if current_user.is_administrator():
if deploy.protected is not True:
try:
query = contact_proxmaster(data, 'vmremove', int(itemid))
flash('Machine {} terminated'.format(itemid))
deploy.cancelled = True
deploy.deleted = True
deploy.enabled = False
deploy.warning = False
db.session.commit()
except:
flash('Cannot delete machine {}'.format(itemid))
return redirect(url_for('admin.list_recyclebin'))
else:
current_app.logger.warning('Deployment id:{} is protected! Cannot be removed'.format(itemid))
else:
current_app.logger.warning('[WARNING] Unauthorized attempt to remove Deployment id:{}'.format(itemid))
abort(404)
@vmanager.route('/activate/<int:itemid>', methods=['GET', 'POST'])
@login_required
def activate(itemid=0):
result = current_user.inv_deployments.filter_by(cancelled=False).all()
result = current_user.inv_deployments.filter_by(deleted=False).all()
inventory = []
for invcls in result:
inventory.extend([invcls.machine_id])
@ -163,6 +145,10 @@ def activate(itemid=0):
deploy.protected = True
db.session.commit()
#router = current_user.inv_routers.filter_by(deleted=False).all()
#if router == []:
transaction = Transaction(user_id=int(owner.pid), description='Deployment {} activated for {} month(s)'.format(str(deploy.machine_alias), form.period.data), value=-total)
db.session.add(transaction)
db.session.commit()
@ -210,23 +196,3 @@ def command(cmd=None, vmid=0):
return redirect(db_result['url'])
abort(404)
#APP STORE
@vmanager.route('/market/<int:group_id>', methods=['GET'])
@login_required
def market(group_id=0):
page = { 'title': 'Market' }
allproducts = Product.get_products()
allgroups = current_app.config['GROUPS']
if group_id == 0:
return render_template('vmanager/market.html', groups=allgroups, products=allproducts)
filtered_products = {}
for key, value in allproducts.items():
if value['group'] == group_id:
filtered_products[key] = value
if filtered_products == {}:
abort(404)
return render_template('vmanager/marketgroup.html', groupname=allgroups[group_id], products=filtered_products)

View file

@ -41,7 +41,7 @@ def autoremove():
from app.models import User, Deployment
today = datetime.utcnow()
print('\nScan for unprotected deployments, lower their days left by 1 and autodelete them if expired. Script Started at {}'.format(today))
drafts = Deployment.query.filter_by(cancelled=False).filter_by(protected=False).all()
drafts = Deployment.query.filter_by(deleted=False).filter_by(protected=False).all()
for draft in drafts:
daysleft = draft.daysleft
daysleft -= 1
@ -58,7 +58,7 @@ def autodisable():
dep_c = 0
srv_c = 0
dom_c = 0
deployments = Deployment.query.filter_by(cancelled=False).filter_by(enabled=True).filter_by(protected=True).all()
deployments = Deployment.query.filter_by(deleted=False).filter_by(enabled=True).filter_by(protected=True).all()
for deploy in deployments:
#print('Found {}.'.format(str(deploy.machine_alias)))
lastcharge = deploy.date_last_charge
@ -71,7 +71,7 @@ def autodisable():
db.session.commit()
else:
dep_c += 1
services_ena = Service.query.filter_by(cancelled=False).filter_by(enabled=True).all()
services_ena = Service.query.filter_by(deleted=False).filter_by(enabled=True).all()
for service in services_ena:
lastcharge = service.date_last_charge
expiry = lastcharge + relativedelta(lastcharge, months=+(service.period))
@ -83,7 +83,7 @@ def autodisable():
db.session.commit()
else:
srv_c += 1
domains_ena = Domain.query.filter_by(cancelled=False).filter_by(enabled=True).all()
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
for domain in domains_ena:
expiry = domain.date_expire
if today > expiry:
@ -101,7 +101,7 @@ def autowarn():
from app.models import User, Deployment, Service, Domain, Transaction
today = datetime.utcnow()
print('\nScan for items that will expire soon and enable the warning flag. Script started at {}'.format(today))
deployments_ena = Deployment.query.filter_by(cancelled=False).filter_by(enabled=True).filter_by(protected=True).all()
deployments_ena = Deployment.query.filter_by(deleted=False).filter_by(enabled=True).filter_by(protected=True).all()
for deploy in deployments_ena:
lastcharge = deploy.date_last_charge
expiry = lastcharge + relativedelta(lastcharge, months=+(deploy.period))
@ -114,7 +114,7 @@ def autowarn():
deploy.warning = True
db.session.commit()
services_ena = Service.query.filter_by(cancelled=False).filter_by(enabled=True).all()
services_ena = Service.query.filter_by(deleted=False).filter_by(enabled=True).all()
for service in services_ena:
lastcharge = service.date_last_charge
expiry = lastcharge + relativedelta(lastcharge, months=+(service.period))
@ -127,7 +127,7 @@ def autowarn():
service.warning = True
db.session.commit()
domains_ena = Domain.query.filter_by(cancelled=False).filter_by(enabled=True).all()
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
for domain in domains_ena:
expiry = domain.date_expire
daysleft = expiry - today