mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
There is a problem where columns on the templates table were not set.
It is also discovered that columns that have a default value and use the version mixin must set the value when creating the db object before the insert otherwise the history table will be missing the default value. Updated the templates_history.created_by_id with a value where missing, using the current version of the template for this value. Update templates_history.archived to false. This is okay as we do not yet have a way to set this value to true. Removed the versions attribute from the TemplateSchema, there is not a need for this column.
This commit is contained in:
@@ -13,6 +13,7 @@ from app.dao.dao_utils import (
|
||||
@version_class(Template)
|
||||
def dao_create_template(template):
|
||||
template.id = uuid.uuid4() # must be set now so version history model can use same id
|
||||
template.archived = False
|
||||
db.session.add(template)
|
||||
|
||||
|
||||
|
||||
@@ -114,11 +114,6 @@ class BaseTemplateSchema(BaseSchema):
|
||||
class TemplateSchema(BaseTemplateSchema):
|
||||
|
||||
created_by = field_for(models.Template, 'created_by', required=True)
|
||||
versions = fields.Method("template_versions", dump_only=True)
|
||||
|
||||
def template_versions(self, template):
|
||||
return [x.version for x in models.Template.get_history_model().query.filter_by(
|
||||
id=template.id).options(load_only("version"))]
|
||||
|
||||
@validates_schema
|
||||
def validate_type(self, data):
|
||||
|
||||
Reference in New Issue
Block a user