Handle deleted chars in pet name association
Fix pre-built obj generation
This commit is contained in:
parent
e9aef0219e
commit
d63dd807e3
@ -111,12 +111,17 @@ def get_pets(status="all"):
|
|||||||
"""
|
"""
|
||||||
pet_data["2"] = "<span class='text-danger'>Rejected</span>"
|
pet_data["2"] = "<span class='text-danger'>Rejected</span>"
|
||||||
|
|
||||||
pet_data["3"] = f"""
|
try:
|
||||||
<a role="button" class="btn btn-primary btn btn-block"
|
pet_data["3"] = f"""
|
||||||
href='{url_for('characters.view', id=pet_data["3"])}'>
|
<a role="button" class="btn btn-primary btn btn-block"
|
||||||
{CharacterInfo.query.filter(CharacterInfo.id==pet_data['3']).first().name}
|
href='{url_for('characters.view', id=pet_data["3"])}'>
|
||||||
</a>
|
{CharacterInfo.query.filter(CharacterInfo.id==pet_data['3']).first().name}
|
||||||
"""
|
</a>
|
||||||
|
"""
|
||||||
|
except Exception as e:
|
||||||
|
PetNames.query.filter(PetNames.id==id).first().delete()
|
||||||
|
pet_data["3"] = "Deleted Character"
|
||||||
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -128,4 +133,7 @@ def accociate_pets_and_owners():
|
|||||||
owner = CharacterXML.query.filter(CharacterXML.xml_data.like(f"%{pet.id}%")).first()
|
owner = CharacterXML.query.filter(CharacterXML.xml_data.like(f"%{pet.id}%")).first()
|
||||||
if owner:
|
if owner:
|
||||||
pet.owner_id = owner.id
|
pet.owner_id = owner.id
|
||||||
pet.save()
|
pet.save()
|
||||||
|
else:
|
||||||
|
pet.delete()
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ from flask import (
|
|||||||
jsonify,
|
jsonify,
|
||||||
send_from_directory,
|
send_from_directory,
|
||||||
make_response,
|
make_response,
|
||||||
flash
|
flash,
|
||||||
|
current_app
|
||||||
)
|
)
|
||||||
from flask_user import login_required, current_user
|
from flask_user import login_required, current_user
|
||||||
import json
|
import json
|
||||||
@ -358,29 +359,29 @@ def prebuilt(content, file_format, lod):
|
|||||||
[render_component_id],
|
[render_component_id],
|
||||||
one=True
|
one=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if filename:
|
if filename:
|
||||||
filename = filename[0].split("\\\\")[-1].lower().split(".")[0]
|
filename = filename[0].split("\\\\")[-1].lower().split(".")[0]
|
||||||
else:
|
else:
|
||||||
return f"No filename for LOT {content.lot}"
|
return f"No filename for LOT {content.lot}"
|
||||||
|
|
||||||
|
lxfml = pathlib.Path(f'app/luclient/res/BrickModels/{filename.split(".")[0]}.lxfml')
|
||||||
if file_format == "lxfml":
|
if file_format == "lxfml":
|
||||||
lxfml = pathilob.Path(f'app/luclient/res/BrickModels/{filename.split(".")[0]}.lxfml')
|
|
||||||
with open(lxfml, 'r') as file:
|
with open(lxfml, 'r') as file:
|
||||||
lxfml_data = file.read()
|
lxfml_data = file.read()
|
||||||
# print(lxfml_data)
|
|
||||||
response = make_response(lxfml_data)
|
response = make_response(lxfml_data)
|
||||||
|
|
||||||
elif file_format in ["obj", "mtl"]:
|
elif file_format in ["obj", "mtl"]:
|
||||||
|
cache = pathlib.Path(f'app/cache/BrickModels/{filename}.lod{lod}.{file_format}')
|
||||||
|
cache.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
try:
|
||||||
|
ldd.main(str(lxfml.as_posix()), str(cache.with_suffix("").as_posix()), lod) # convert to OBJ
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.error(f"ERROR on {cache}:\n {e}")
|
||||||
|
|
||||||
cache = f"app/cache/BrickModels/{filename}.lod{lod}.{file_format}"
|
with open(str(cache.as_posix()), 'r') as file:
|
||||||
|
|
||||||
if not os.path.exists(cache):
|
|
||||||
lxfml = f'app/luclient/res/BrickModels/{filename.split(".")[0]}.lxfml'
|
|
||||||
ldd.main(lxfml, cache.split('.')[0]) # convert to OBJ
|
|
||||||
|
|
||||||
with open(cache, 'r') as file:
|
|
||||||
cache_data = file.read()
|
cache_data = file.read()
|
||||||
|
|
||||||
response = make_response(cache_data)
|
response = make_response(cache_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user