Handle deleted chars in pet name association

Fix pre-built obj generation
This commit is contained in:
Aaron Kimbre
2022-02-12 19:09:45 -06:00
parent e9aef0219e
commit d63dd807e3
2 changed files with 27 additions and 18 deletions

View File

@@ -111,12 +111,17 @@ def get_pets(status="all"):
"""
pet_data["2"] = "<span class='text-danger'>Rejected</span>"
pet_data["3"] = f"""
<a role="button" class="btn btn-primary btn btn-block"
href='{url_for('characters.view', id=pet_data["3"])}'>
{CharacterInfo.query.filter(CharacterInfo.id==pet_data['3']).first().name}
</a>
"""
try:
pet_data["3"] = f"""
<a role="button" class="btn btn-primary btn btn-block"
href='{url_for('characters.view', id=pet_data["3"])}'>
{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
@@ -128,4 +133,7 @@ def accociate_pets_and_owners():
owner = CharacterXML.query.filter(CharacterXML.xml_data.like(f"%{pet.id}%")).first()
if owner:
pet.owner_id = owner.id
pet.save()
pet.save()
else:
pet.delete()