infer template/service from job for notification/ft_noti_status in db.py

This commit is contained in:
Leo Hemsted
2018-12-12 12:57:04 +00:00
parent 4ddd38b440
commit bf62d3ad5f
2 changed files with 9 additions and 1 deletions

View File

@@ -1101,7 +1101,9 @@ def restore_provider_details(notify_db, notify_db_session):
@pytest.fixture @pytest.fixture
def admin_request(client): def admin_request(client):
class AdminRequest: class AdminRequest:
app = client.application
@staticmethod @staticmethod
def get(endpoint, _expected_status=200, **endpoint_kwargs): def get(endpoint, _expected_status=200, **endpoint_kwargs):

View File

@@ -164,7 +164,7 @@ def create_template(
def create_notification( def create_notification(
template, template=None,
job=None, job=None,
job_row_number=None, job_row_number=None,
to_field=None, to_field=None,
@@ -190,6 +190,10 @@ def create_notification(
created_by_id=None, created_by_id=None,
postage=None postage=None
): ):
assert job or template
if job:
template = job.template
if created_at is None: if created_at is None:
created_at = datetime.utcnow() created_at = datetime.utcnow()
@@ -557,6 +561,8 @@ def create_ft_notification_status(
notification_status='delivered', notification_status='delivered',
count=1 count=1
): ):
if job:
template = job.template
if template: if template:
service = template.service service = template.service
notification_type = template.template_type notification_type = template.template_type