From e8ce408f6a9a68149feabaf099bc8cf83c31559b Mon Sep 17 00:00:00 2001 From: Alexey Bezhan Date: Wed, 22 Nov 2017 15:55:11 +0000 Subject: [PATCH] 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. --- app/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models.py b/app/models.py index a2187fcb4..a1322cf75 100644 --- a/app/models.py +++ b/app/models.py @@ -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)