From 0066e0ea2d8618c04d9533e47423e762133ed7c0 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Wed, 2 Feb 2022 21:18:21 -0600 Subject: [PATCH] added char_xml download fix bad call in luclient.get_lot_name Don't show rank for rank 0 fixes --- .gitattributes | 1 - README.md | 2 +- app/characters.py | 43 ++++++++++++++++++- app/luclient.py | 2 +- app/templates/ldd/ldd.html.j2 | 3 -- .../partials/charxml/_item_tooltip.html.j2 | 3 +- 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.gitattributes b/.gitattributes index 6d27232..930cc70 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ app/static/bootstrap-4.2.1/* linguist-vendored=true -app/static/bootswatch-master/* linguist-vendored=true app/static/datatables/* linguist-vendored=true app/static/font-awesome/* linguist-vendored=true diff --git a/README.md b/README.md index 0610c20..7f4acdc 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ docker run -d \ * /app/luclient must be mapped to the location of an unpacked client * you only need `res/` and `locale/` from the client, but dropping the whole cleint in there won't hurt * Use `fdb_to_sqlite.py` in lcdr's utilities on `res/cdclient.fdb` in the unpacked client to convert the client database to `cdclient.sqlite` - * Put teh resulting `cdclient.sqlite` in the res folder: `res/cdclient.sqlite` + * Put the resulting `cdclient.sqlite` in the res folder: `res/cdclient.sqlite` * unzip `res/brickdb.zip` in-place * **Docker will do this for you** * you should have new folders and files in the following places: diff --git a/app/characters.py b/app/characters.py index a6a099f..8c5b6aa 100644 --- a/app/characters.py +++ b/app/characters.py @@ -1,4 +1,4 @@ -from flask import render_template, Blueprint, redirect, url_for, request, abort, flash +from flask import render_template, Blueprint, redirect, url_for, request, abort, flash, make_response from flask_user import login_required, current_user import json from datatables import ColumnDT, DataTables @@ -87,6 +87,47 @@ def view(id): ) +@character_blueprint.route('/view_xml/', methods=['GET']) +@login_required +def view_xml(id): + + character_data = CharacterInfo.query.filter(CharacterInfo.id == id).first() + + if character_data == {}: + abort(404) + return + + character_xml = CharacterXML.query.filter( + CharacterXML.id==id + ).first().xml_data + + response = make_response(character_xml) + response.headers.set('Content-Type', 'text/xml') + return response + +@character_blueprint.route('/get_xml/', methods=['GET']) +@login_required +def get_xml(id): + + character_data = CharacterInfo.query.filter(CharacterInfo.id == id).first() + + if character_data == {}: + abort(404) + return + + character_xml = CharacterXML.query.filter( + CharacterXML.id==id + ).first().xml_data + + response = make_response(character_xml) + response.headers.set('Content-Type', 'attachment/xml') + response.headers.set( + 'Content-Disposition', + 'attachment', + filename=f"{character_data.name}.xml" + ) + return response + @character_blueprint.route('/restrict//', methods=['GET']) @login_required @gm_level(3) diff --git a/app/luclient.py b/app/luclient.py index 5957db1..4f6415a 100644 --- a/app/luclient.py +++ b/app/luclient.py @@ -233,7 +233,7 @@ def register_luclient_jinja_helpers(app): @app.template_filter('get_lot_name') def get_lot_name(lot_id): name = translate_from_locale(f'Objects_{lot_id}_name') - if name == translate_from_locale(f'Objects_{lot_id}_name'): + if name == f'Objects_{lot_id}_name': intermed = query_cdclient( 'select * from Objects where id = ?', [lot_id], diff --git a/app/templates/ldd/ldd.html.j2 b/app/templates/ldd/ldd.html.j2 index 64f60be..7dd506d 100644 --- a/app/templates/ldd/ldd.html.j2 +++ b/app/templates/ldd/ldd.html.j2 @@ -747,11 +747,8 @@ // let vnh = new VertexNormalsHelper( mesh, 5 ); // scene.add( vnh ); } - - } } - } } diff --git a/app/templates/partials/charxml/_item_tooltip.html.j2 b/app/templates/partials/charxml/_item_tooltip.html.j2 index 9d92748..3dbc072 100644 --- a/app/templates/partials/charxml/_item_tooltip.html.j2 +++ b/app/templates/partials/charxml/_item_tooltip.html.j2 @@ -8,7 +8,8 @@
--------------------------------
- {{ ("ItemSets_" ~ item_set[0] ~ "_kitName")|lu_translate }}: Rank {{ item_set[4] }}
+ + {{ ("ItemSets_" ~ item_set[0] ~ "_kitName")|lu_translate }}{% if item_set[4]|int > 0%}: Rank {{ item_set[4] }}{% endif %}
{% if item_set[5] %}