remove .format() and get all updates to have crrect content
This commit is contained in:
12
covertype.py
12
covertype.py
@@ -15,7 +15,7 @@ class Covertype(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 Covertype into json / useful in jinja2
|
||||
@@ -58,11 +58,11 @@ def new_covertype():
|
||||
try:
|
||||
db.session.add(covertype)
|
||||
db.session.commit()
|
||||
st.SetMessage( "Created new Covertype (id={})".format(covertype.id) )
|
||||
st.SetMessage( f"Created new Covertype (id={covertype.id})" )
|
||||
return redirect( '/covertypes' )
|
||||
except SQLAlchemyError as e:
|
||||
st.SetAlert( "danger" )
|
||||
st.SetMessage( "<b>Failed to add covertype:</b> {}".format( e.orig) )
|
||||
st.SetMessage( f"<b>Failed to add covertype:</b> {e.orig}" )
|
||||
return render_template("edit_id_name.html", form=form, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
|
||||
|
||||
@@ -79,16 +79,16 @@ def covertype(id):
|
||||
try:
|
||||
covertype = Covertype.query.get(id)
|
||||
if 'delete' in request.form:
|
||||
st.SetMessage("Successfully deleted (id={}, name={})".format( covertype.id, covertype.name ) )
|
||||
st.SetMessage( f"Successfully deleted (id={covertype.id}, name={covertype.name})" )
|
||||
covertype = Covertype.query.filter(Covertype.id==id).delete()
|
||||
if 'submit' in request.form:
|
||||
st.SetMessage("Successfully Updated Covertype (id={})".format(id) )
|
||||
st.SetMessage( f"Successfully Updated Covertype (id={id})" )
|
||||
covertype.name = request.form['name']
|
||||
db.session.commit()
|
||||
return redirect( '/covertypes' )
|
||||
except SQLAlchemyError as e:
|
||||
st.SetAlert( "danger" )
|
||||
st.SetMessage( "<b>Failed to modify Covertype:</b> {}".format(e.orig) )
|
||||
st.SetMessage( f"<b>Failed to modify Covertype:</b> {e.orig}" )
|
||||
return render_template("edit_id_name.html", form=form, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
else:
|
||||
covertype = Covertype.query.get(id)
|
||||
|
||||
Reference in New Issue
Block a user