remove .format() and get all updates to have crrect content
This commit is contained in:
12
publisher.py
12
publisher.py
@@ -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> {}".format( e.orig) )
|
||||
st.SetMessage( f"<b>Failed to add Publisher:</b> {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> {}".format(e.orig) )
|
||||
st.SetMessage( f"<b>Failed to modify Publisher:</b> {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)
|
||||
|
||||
Reference in New Issue
Block a user