mirror of
https://github.com/GSA/notifications-api.git
synced 2026-04-05 09:59:17 -04:00
Fix an intermittent test failure when creating a template with reply_to
reply_to requires template_type to be already set, but the order of attribute assignment is not defined when a model object is created from a dictionary. This adds a constructor to Template model that makes sure that template_type is set first when multiple arguments are passed to the constructor at once. The problem might still exist when the template is created through the API, so this is a temporary fix to unblock the release.
This commit is contained in:
@@ -526,6 +526,12 @@ class TemplateProcessTypes(db.Model):
|
||||
class TemplateBase(db.Model):
|
||||
__abstract__ = True
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
if 'template_type' in kwargs:
|
||||
self.template_type = kwargs.pop('template_type')
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
name = db.Column(db.String(255), nullable=False)
|
||||
template_type = db.Column(template_types, nullable=False)
|
||||
|
||||
Reference in New Issue
Block a user