remove .format() and get all updates to have crrect content

This commit is contained in:
2022-07-03 20:38:33 +10:00
parent 8834893df3
commit 021bf91e16
12 changed files with 81 additions and 59 deletions

View File

@@ -15,7 +15,7 @@ class Owned(db.Model):
name = db.Column(db.String(50), unique=True, nullable=False)
def __repr__(self):
return "<id: {}, name: {}>".format(self.id,self.name)
return f"<id: {self.id}, name: {self.name}>"
################################################################################
# Helper class that inherits a .dump() method to turn class Owned into json / useful in jinja2
@@ -58,11 +58,11 @@ def new_owned():
try:
db.session.add(owned)
db.session.commit()
st.SetMessage( "Created new Owned Type (id={})".format(owned.id) )
st.SetMessage( f"Created new Owned Type (id={owned.id})" )
return redirect( '/owneds' )
except SQLAlchemyError as e:
st.SetAlert( "danger" )
st.SetMessage( "<b>Failed to add Ownership type:</b>&nbsp;{}".format( e.orig) )
st.SetMessage( f"<b>Failed to add Ownership type:</b>&nbsp;{e.orig}" )
return render_template("edit_id_name.html", form=form, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
################################################################################
@@ -77,16 +77,16 @@ def owned(id):
try:
owned = Owned.query.get(id)
if 'delete' in request.form:
st.SetMessage("Successfully deleted (id={}, name={})".format( owned.id, owned.name ) )
st.SetMessage( f"Successfully deleted (id={owned.id}, name={owned.name})" )
owned = Owned.query.filter(Owned.id==id).delete()
if 'submit' in request.form:
owned.name = request.form['name']
st.SetMessage("Successfully Updated Owned (id={})".format(id) )
st.SetMessage( f"Successfully Updated Owned (id={id})" )
db.session.commit()
return redirect( '/owneds' )
except SQLAlchemyError as e:
st.SetAlert( "danger" )
st.SetMessage( "<b>Failed to modify Ownership Type:</b>&nbsp;{}".format(e.orig) )
st.SetMessage( f"<b>Failed to modify Ownership Type:</b>&nbsp;{e.orig}" )
return render_template("edit_id_name.html", form=form, page_title='Edit Ownership Type', alert=st.GetAlert(), message=st.GetMessage() )
else:
obj = Owned.query.get(id)