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 Publisher(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 Publisher into json / useful in jinja2
@@ -58,11 +58,11 @@ def new_publisher():
try:
db.session.add(publisher)
db.session.commit()
st.SetMessage( "Created new Publisher (id={})".format(publisher.id) )
st.SetMessage( f"Created new Publisher (id={publisher.id})" )
return redirect( '/publishers' )
except SQLAlchemyError as e:
st.SetAlert( "danger" )
st.SetMessage( "<b>Failed to add Publisher:</b>&nbsp;{}".format( e.orig) )
st.SetMessage( f"<b>Failed to add Publisher:</b>&nbsp;{e.orig}" )
return render_template("edit_id_name.html", form=form, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
################################################################################
@@ -78,16 +78,16 @@ def publisher(id):
try:
publisher = Publisher.query.get(id)
if 'delete' in request.form:
st.SetMessage("Successfully deleted (id={}, name={})".format( publisher.id, publisher.name ) )
st.SetMessage( f"Successfully deleted (id={publisher.id}, name={publisher.name})" )
publisher = Publisher.query.filter(Publisher.id==id).delete()
if 'submit' in request.form:
st.SetMessage("Successfully Updated Publisher (id={})".format(id) )
st.SetMessage( f"Successfully Updated Publisher (id={id})" )
publisher.name = request.form['name']
db.session.commit()
return redirect( '/publishers' )
except SQLAlchemyError as e:
st.SetAlert( "danger" )
st.SetMessage( "<b>Failed to modify Publisher:</b>&nbsp;{}".format(e.orig) )
st.SetMessage( f"<b>Failed to modify Publisher:</b>&nbsp;{e.orig}" )
return render_template("edit_id_name.html", form=form, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
else:
publisher = Publisher.query.get(id)