diff --git a/app/admin/forms.py b/app/admin/forms.py index 6d7ce52..9fa39a1 100644 --- a/app/admin/forms.py +++ b/app/admin/forms.py @@ -8,6 +8,6 @@ from wtforms import validators, ValidationError from wtforms.fields.html5 import EmailField class ChargeForm(FlaskForm): - amount = DecimalField('Стойност:', [validators.DataRequired(), validators.NumberRange(min=0, max=6)]) + amount = DecimalField('Стойност:', [validators.DataRequired(), validators.NumberRange(min=1, max=500)]) submit = SubmitField('Зареди') diff --git a/app/admin/routes.py b/app/admin/routes.py index ad5c03e..d91cbdc 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -7,7 +7,7 @@ from .forms import ChargeForm from .. import db from ..email import send_email -from ..models import User, Role, Deployment, Service, Region, Address, Domain, contact_proxmaster +from ..models import User, Deployment, Service, Region, Address, Domain, contact_proxmaster from ..decorators import admin_required, permission_required import base64 @@ -31,6 +31,16 @@ def after_request(response): @admin.route("/", methods=['GET']) @login_required @admin_required +def index(): + alldeployments = Deployment.query.order_by(Deployment.date_created.desc()).all() + alldomains = Domain.query.order_by(Domain.date_created.desc()).all() + allservices = Service.query.order_by(Service.date_created.desc()).all() + alladdresses = Address.query.order_by(Address.date_assigned.desc()).all() + return render_template('admin/index.html', deployments=alldeployments, domains=alldomains, services=allservices, addresses=alladdresses) + +@admin.route("/users", methods=['GET']) +@login_required +@admin_required def users(): allusers = User.query.order_by(User.pid.asc()).all() return render_template('admin/users.html', users=allusers) @@ -42,7 +52,7 @@ def charge(user_pid=0): cuser = User.query.filter_by(pid=user_pid).first() form = ChargeForm() if form.validate_on_submit(): - cuser.wallet += form.amount.data + cuser.wallet += float(form.amount.data) db.session.add(cuser) db.session.commit() return redirect(url_for('admin.users')) diff --git a/app/models.py b/app/models.py index 29d796b..eff2db6 100644 --- a/app/models.py +++ b/app/models.py @@ -160,7 +160,10 @@ class User(db.Model, UserMixin): return self.role is not None and (self.role.permissions & permissions) == permissions def is_administrator(self): - return self.can(Permission.ADMINISTER) + if self.can(Permission.ADMINISTER): + return True + else: + return False def ping(self): self.last_seen = datetime.utcnow() @@ -288,6 +291,7 @@ class Address(db.Model): ip = db.Column(db.String(64)) rdns = db.Column(db.String(256)) macaddr = db.Column(db.String(128)) + reserved = db.Column(db.Boolean, default=False) class Domain(db.Model): __tablename__ = 'domains' diff --git a/app/templates/admin/admin_tasks.html b/app/templates/admin/admin_tasks.html new file mode 100644 index 0000000..c438a55 --- /dev/null +++ b/app/templates/admin/admin_tasks.html @@ -0,0 +1,10 @@ +
+
Cube ID | +Alias | +CPU | +Mem | +HDD | +Owner | +
---|---|---|---|---|---|
{% if deploy.enabled == True %}{% else %}{% endif %}{{ deploy.machine_id }} | +{{ deploy.machine_alias }} | +{{ deploy.machine_cpu }} Cores | +{{ deploy.machine_mem }} MB | +{{ deploy.machine_hdd }} GB | +{{ deploy.owner.email }} | + {% endfor %} +
+
Name | +Expiry Date | +Owner | +
---|---|---|
{{ domain.fqdn }} | +{{ domain.date_expire }} | +{{ domain.owner.email }} | +
+
IP | +Reverse DNS | +MAC Addr. | +Owner | +
---|---|---|---|
{{ address.ip }} | +{{ address.rdns }} | +{{ address.macaddr }} | +{{ address.owner.email }} | + {% endfor %} +
+
Name | +Description | +Unit | +Price | +|
---|---|---|---|---|
{{ service.name }} | +{{ service.description }} | +{{ service.unit }} | +{{ service.unitprice }} | +{{ service.owner.email }} | +