diff --git a/app/characters.py b/app/characters.py index f85c617..c963631 100644 --- a/app/characters.py +++ b/app/characters.py @@ -30,14 +30,20 @@ def approve_name(id, action): character = CharacterInfo.query.filter(CharacterInfo.id == id).first() 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: character.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 elif action == "rename": diff --git a/app/luclient.py b/app/luclient.py index 3bf9517..eb4da3a 100644 --- a/app/luclient.py +++ b/app/luclient.py @@ -282,7 +282,9 @@ def register_luclient_jinja_helpers(app): 'select component_id from ComponentsRegistry where component_type = 11 and id = ?', [lot_id], one=True - )[0] + ) + if render_component_id: + render_component_id = render_component_id[0] rarity = query_cdclient( 'select rarity from ItemComponent where id = ?', diff --git a/app/models.py b/app/models.py index bdd2469..566d9a3 100644 --- a/app/models.py +++ b/app/models.py @@ -114,7 +114,7 @@ class PlayKey(db.Model): ) db.session.add(new_key) db.session.commit() - return key + return key def delete(self): db.session.delete(self) diff --git a/app/reports.py b/app/reports.py index 5b2b2d7..db830b0 100644 --- a/app/reports.py +++ b/app/reports.py @@ -6,7 +6,6 @@ from app import gm_level, scheduler from sqlalchemy.orm import load_only import datetime import xmltodict -import random reports_blueprint = Blueprint('reports', __name__) @@ -32,7 +31,6 @@ def index(): ).filter( Reports.report_type == "uscore" ).group_by(Reports.date).options(load_only(Reports.date)).all() - return render_template( 'reports/index.html.j2', reports_items=reports_items, @@ -69,20 +67,24 @@ def items_graph(start, end): items[key] = get_lot_name(key) # make it for key, value in items.items(): - data = [] - for entry in entries: - if key in entry.data.keys(): - data.append(entry.data[key]) - else: - data.append(0) - color = "#" + value.encode("utf-8").hex()[1:7] - if max(data) > 10: - datasets.append({ - "label": value, - "data": data, - "backgroundColor": color, - "borderColor": color - }) + if value: + data = [] + for entry in entries: + if key in entry.data.keys(): + if not isinstance(entry.data[key], int): + data.append(entry.data[key]["item_count"]) + else: + data.append(entry.data[key]) + else: + data.append(0) + color = "#" + value.encode("utf-8").hex()[1:7] + if max(data) > 10: + datasets.append({ + "label": value, + "data": data, + "backgroundColor": color, + "borderColor": color + }) return render_template( 'reports/graph.html.j2', @@ -224,6 +226,7 @@ def gen_item_report(): report_data = {} for char_xml in char_xmls: + name = CharacterInfo.query.filter(CharacterInfo.id == char_xml.id).first().name try: character_json = xmltodict.parse( 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): for item in inv["i"]: 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: - 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: current_app.logger.error(f"REPORT::ITEMS - ERROR PARSING CHARACTER {char_xml.id}") current_app.logger.error(f"REPORT::ITEMS - {e}") diff --git a/app/templates/reports/items/by_date.html.j2 b/app/templates/reports/items/by_date.html.j2 index aeaca58..ee56f2e 100644 --- a/app/templates/reports/items/by_date.html.j2 +++ b/app/templates/reports/items/by_date.html.j2 @@ -20,18 +20,34 @@