Fix for missing template IDs.

- Problem was that on notification creation we pass the template ID not the template onto the new notification object
- We then set the history object from this notification object by copying all the fields. This is OK at this point.
- We then set the relationship on the history object based on the template, which we haven't passed in. We only passed the ID. This means that SQLAlchemy nulls the relationship, removing the template_id.
- Later we update the history row when we send the message, this fixes the data. BUT if we ever have a send error, then this never happens and the template is never set on the history table.

Fix:
Set only the template ID when creating the history object.
This commit is contained in:
Martyn Inglis
2016-12-15 16:59:03 +00:00
parent f91a2b67f1
commit 2924f01f95
4 changed files with 26 additions and 7 deletions

View File

@@ -3,8 +3,6 @@ import json
from freezegun import freeze_time
from app import db
from app.models import TemplateStatistics
from tests import create_authorization_header
from tests.app.conftest import sample_template as create_sample_template, sample_template, sample_notification, \
sample_email_template