mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-21 21:17:23 +00:00
Add property reputation handling
This commit is contained in:
parent
560afa5e0d
commit
7f992a5dfa
@ -75,14 +75,14 @@ def create_app():
|
||||
if cdclient is not None:
|
||||
cdclient.close()
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
def handle_exception(e):
|
||||
app.logger.error(e)
|
||||
# pass through HTTP errors
|
||||
if isinstance(e, HTTPException):
|
||||
return e
|
||||
# now you're handling non-HTTP exceptions only
|
||||
return render_template("status_codes/500.html.j2", exception=e), 500
|
||||
# @app.errorhandler(Exception)
|
||||
# def handle_exception(e):
|
||||
# app.logger.error(e)
|
||||
# # pass through HTTP errors
|
||||
# if isinstance(e, HTTPException):
|
||||
# return e
|
||||
# # now you're handling non-HTTP exceptions only
|
||||
# return render_template("status_codes/500.html.j2", exception=e), 500
|
||||
|
||||
# add the commands to flask cli
|
||||
app.cli.add_command(init_db)
|
||||
|
@ -8,6 +8,7 @@ from flask_sqlalchemy import BaseQuery
|
||||
from sqlalchemy.dialects import mysql
|
||||
from sqlalchemy.exc import OperationalError, StatementError
|
||||
from sqlalchemy.types import JSON
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
||||
from time import sleep
|
||||
import random
|
||||
import string
|
||||
@ -694,6 +695,15 @@ class Property(db.Model):
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
performance_cost = db.Column(
|
||||
mysql.DOUBLE(
|
||||
precision=20,
|
||||
scale=15,
|
||||
asdecimal=False
|
||||
),
|
||||
server_default='0.0'
|
||||
)
|
||||
|
||||
zone_id = db.Column(
|
||||
mysql.INTEGER,
|
||||
nullable=False,
|
||||
|
@ -123,8 +123,9 @@ def get(status="all"):
|
||||
ColumnDT(Property.time_claimed), # 9
|
||||
ColumnDT(Property.rejection_reason), # 10
|
||||
ColumnDT(Property.reputation), # 11
|
||||
ColumnDT(Property.zone_id), # 12
|
||||
ColumnDT(Account.username) # 13
|
||||
ColumnDT(Property.performance_cost), # 12
|
||||
ColumnDT(Property.zone_id), # 13
|
||||
ColumnDT(Account.username) # 14
|
||||
]
|
||||
|
||||
query = None
|
||||
@ -146,6 +147,7 @@ def get(status="all"):
|
||||
rowTable = DataTables(params, query, columns)
|
||||
|
||||
data = rowTable.output_result()
|
||||
print(data)
|
||||
for property_data in data["data"]:
|
||||
id = property_data["0"]
|
||||
|
||||
@ -181,7 +183,7 @@ def get(status="all"):
|
||||
if property_data["4"] == "":
|
||||
property_data["4"] = query_cdclient(
|
||||
'select DisplayDescription from ZoneTable where zoneID = ?',
|
||||
[property_data["12"]],
|
||||
[property_data["13"]],
|
||||
one=True
|
||||
)
|
||||
|
||||
@ -200,9 +202,9 @@ def get(status="all"):
|
||||
else:
|
||||
property_data["7"] = '''<h2 class="far fa-check-square text-success"></h2>'''
|
||||
|
||||
property_data["12"] = query_cdclient(
|
||||
property_data["13"] = query_cdclient(
|
||||
'select DisplayDescription from ZoneTable where zoneID = ?',
|
||||
[property_data["12"]],
|
||||
[property_data["13"]],
|
||||
one=True
|
||||
)
|
||||
|
||||
|
@ -69,6 +69,14 @@
|
||||
{{ property.reputation }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
Performance Cost:
|
||||
</div>
|
||||
<div class="col">
|
||||
{{ property.performance_cost }}
|
||||
</div>
|
||||
</div>
|
||||
{% if request.endpoint != "properties.view" %}
|
||||
<br/>
|
||||
<div class="row">
|
||||
|
@ -32,6 +32,7 @@
|
||||
<th>Claimed</th>
|
||||
<th>Rejection Reason</th>
|
||||
<th>Reputation</th>
|
||||
<th>Performance Cost</th>
|
||||
<th>Location</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -0,0 +1,56 @@
|
||||
"""property performance index
|
||||
|
||||
Revision ID: fa97b0d0c351
|
||||
Revises: b470795db8e1
|
||||
Create Date: 2022-03-31 10:38:06.367277
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy.engine import reflection
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'fa97b0d0c351'
|
||||
down_revision = 'b470795db8e1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
if not _table_has_column('properties', 'performance_cost'):
|
||||
op.add_column(
|
||||
'properties',
|
||||
sa.Column(
|
||||
'performance_cost',
|
||||
mysql.DOUBLE(
|
||||
precision=20,
|
||||
scale=15,
|
||||
asdecimal=False
|
||||
),
|
||||
server_default='0.0',
|
||||
nullable=True
|
||||
)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('properties', 'performance_cost')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def _table_has_column(table, column):
|
||||
config = op.get_context().config
|
||||
engine = engine_from_config(
|
||||
config.get_section(config.config_ini_section), prefix='sqlalchemy.')
|
||||
insp = reflection.Inspector.from_engine(engine)
|
||||
has_column = False
|
||||
for col in insp.get_columns(table):
|
||||
if column not in col['name']:
|
||||
continue
|
||||
has_column = True
|
||||
return has_column
|
Loading…
Reference in New Issue
Block a user