Merge branch 'main' into issue-31

This commit is contained in:
Aaron Kimbre 2022-06-09 09:13:08 -05:00
commit 200370709c
5 changed files with 58 additions and 27 deletions

View File

@ -30,14 +30,20 @@ def approve_name(id, action):
character = CharacterInfo.query.filter(CharacterInfo.id == id).first() character = CharacterInfo.query.filter(CharacterInfo.id == id).first()
if action == "approve": if action == "approve":
log_audit(f"Approved ({character.id}){character.pending_name} from {character.name}")
flash(
f"Approved ({character.id}){character.pending_name} from {character.name}",
"success"
)
if character.pending_name: if character.pending_name:
character.name = character.pending_name character.name = character.pending_name
character.pending_name = "" character.pending_name = ""
log_audit(f"Approved ({character.id}){character.pending_name} from {character.name}")
flash(
f"Approved ({character.id}){character.pending_name} from {character.name}",
"success"
)
else:
log_audit("Cannot make character name empty")
flash(
"Cannot make character name empty",
"danger"
)
character.needs_rename = False character.needs_rename = False
elif action == "rename": elif action == "rename":

View File

@ -282,7 +282,9 @@ def register_luclient_jinja_helpers(app):
'select component_id from ComponentsRegistry where component_type = 11 and id = ?', 'select component_id from ComponentsRegistry where component_type = 11 and id = ?',
[lot_id], [lot_id],
one=True one=True
)[0] )
if render_component_id:
render_component_id = render_component_id[0]
rarity = query_cdclient( rarity = query_cdclient(
'select rarity from ItemComponent where id = ?', 'select rarity from ItemComponent where id = ?',

View File

@ -114,7 +114,7 @@ class PlayKey(db.Model):
) )
db.session.add(new_key) db.session.add(new_key)
db.session.commit() db.session.commit()
return key return key
def delete(self): def delete(self):
db.session.delete(self) db.session.delete(self)

View File

@ -6,7 +6,6 @@ from app import gm_level, scheduler
from sqlalchemy.orm import load_only from sqlalchemy.orm import load_only
import datetime import datetime
import xmltodict import xmltodict
import random
reports_blueprint = Blueprint('reports', __name__) reports_blueprint = Blueprint('reports', __name__)
@ -32,7 +31,6 @@ def index():
).filter( ).filter(
Reports.report_type == "uscore" Reports.report_type == "uscore"
).group_by(Reports.date).options(load_only(Reports.date)).all() ).group_by(Reports.date).options(load_only(Reports.date)).all()
return render_template( return render_template(
'reports/index.html.j2', 'reports/index.html.j2',
reports_items=reports_items, reports_items=reports_items,
@ -69,20 +67,24 @@ def items_graph(start, end):
items[key] = get_lot_name(key) items[key] = get_lot_name(key)
# make it # make it
for key, value in items.items(): for key, value in items.items():
data = [] if value:
for entry in entries: data = []
if key in entry.data.keys(): for entry in entries:
data.append(entry.data[key]) if key in entry.data.keys():
else: if not isinstance(entry.data[key], int):
data.append(0) data.append(entry.data[key]["item_count"])
color = "#" + value.encode("utf-8").hex()[1:7] else:
if max(data) > 10: data.append(entry.data[key])
datasets.append({ else:
"label": value, data.append(0)
"data": data, color = "#" + value.encode("utf-8").hex()[1:7]
"backgroundColor": color, if max(data) > 10:
"borderColor": color datasets.append({
}) "label": value,
"data": data,
"backgroundColor": color,
"borderColor": color
})
return render_template( return render_template(
'reports/graph.html.j2', 'reports/graph.html.j2',
@ -224,6 +226,7 @@ def gen_item_report():
report_data = {} report_data = {}
for char_xml in char_xmls: for char_xml in char_xmls:
name = CharacterInfo.query.filter(CharacterInfo.id == char_xml.id).first().name
try: try:
character_json = xmltodict.parse( character_json = xmltodict.parse(
char_xml.xml_data, char_xml.xml_data,
@ -233,9 +236,13 @@ def gen_item_report():
if "i" in inv.keys() and type(inv["i"]) == list and (int(inv["attr_t"]) == 0 or int(inv["attr_t"]) == 1): if "i" in inv.keys() and type(inv["i"]) == list and (int(inv["attr_t"]) == 0 or int(inv["attr_t"]) == 1):
for item in inv["i"]: for item in inv["i"]:
if item["attr_l"] in report_data: if item["attr_l"] in report_data:
report_data[item["attr_l"]] = report_data[item["attr_l"]] + int(item["attr_c"]) report_data[item["attr_l"]]["item_count"] = report_data[item["attr_l"]]["item_count"] + int(item["attr_c"])
else: else:
report_data[item["attr_l"]] = int(item["attr_c"]) report_data[item["attr_l"]] = {"item_count": int(item["attr_c"]), "chars": {}}
if name in report_data[item["attr_l"]]["chars"]:
report_data[item["attr_l"]]["chars"][name] = report_data[item["attr_l"]]["chars"][name] + int(item["attr_c"])
else:
report_data[item["attr_l"]]["chars"][name] = int(item["attr_c"])
except Exception as e: except Exception as e:
current_app.logger.error(f"REPORT::ITEMS - ERROR PARSING CHARACTER {char_xml.id}") current_app.logger.error(f"REPORT::ITEMS - ERROR PARSING CHARACTER {char_xml.id}")
current_app.logger.error(f"REPORT::ITEMS - {e}") current_app.logger.error(f"REPORT::ITEMS - {e}")

View File

@ -20,18 +20,34 @@
<th scope="col"> <th scope="col">
Count Count
</th> </th>
<th scope="col">
Breakdown
</th>
<th scope="col"> <th scope="col">
Rarity Rarity
</th> </th>
</thead> </thead>
<tbody> <tbody>
{% for lot, count in data.items() %} {% for lot, details in data.items() %}
<tr> <tr>
<td> <td>
{{ lot|get_lot_name }} {{ lot|get_lot_name }}
</td> </td>
<td> <td>
{{ count }} {% if details.chars %}
{{ details.item_count }}
{% else %}
{{ details }}
{% endif %}
</td>
<td>
{% if details.chars %}
{% for char, value in details.chars|dictsort(false, 'value')|reverse %}
{{char}}: {{value}}<br/>
{% endfor %}
{% else %}
Missing
{% endif %}
</td> </td>
<td> <td>
{{ lot|get_lot_rarity }} {{ lot|get_lot_rarity }}