put ordering into Author object so fields render as surname before firstname

This commit is contained in:
2020-11-16 00:01:33 +11:00
parent 1de0ed27d9
commit ff749dfdf5

View File

@@ -7,8 +7,8 @@ from __main__ import db, app, ma
################################################################################
class Author(db.Model):
id = db.Column(db.Integer, unique=True, nullable=False, primary_key=True)
firstnames = db.Column(db.String(50), unique=False, nullable=False)
surname = db.Column(db.String(30), unique=False, nullable=False)
firstnames = db.Column(db.String(50), unique=False, nullable=False)
def __repr__(self):
return "<id: {}, firstnames: {}, surname: {}>".format(self.id,self.firstnames, self.surname)
@@ -17,7 +17,9 @@ class Author(db.Model):
# Helper class that inherits a .dump() method to turn class Author into json / useful in jinja2
################################################################################
class AuthorSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = Author
class Meta:
model = Author
ordered = True
################################################################################
# Helper class that defines a form for author, used to make html <form>, with field validation (via wtforms)