Merge branch 'master' into do-not-write-test-data-to-the-history-table

Conflicts:
	app/dao/notifications_dao.py
This commit is contained in:
Rebecca Law
2016-12-21 09:57:17 +00:00
13 changed files with 269 additions and 181 deletions

View File

@@ -132,7 +132,7 @@ def dao_create_notification(notification):
db.session.add(notification)
if _should_record_notification_in_history_table(notification):
db.session.add(NotificationHistory.from_notification(notification))
db.session.add(NotificationHistory.from_original(notification))
def _should_record_notification_in_history_table(notification):
@@ -200,7 +200,7 @@ def dao_update_notification(notification):
db.session.add(notification)
if _should_record_notification_in_history_table(notification):
notification_history = NotificationHistory.query.get(notification.id)
notification_history.update_from_notification(notification)
notification_history.update_from_original(notification)
db.session.add(notification_history)
db.session.commit()

View File

@@ -1,6 +1,8 @@
from datetime import datetime
from sqlalchemy import asc
from app.dao.dao_utils import transactional
from app.models import ProviderDetails
from app.models import ProviderDetails, ProviderDetailsHistory
from app import db
@@ -20,4 +22,8 @@ def get_provider_details_by_notification_type(notification_type):
@transactional
def dao_update_provider_details(provider_details):
provider_details.version += 1
provider_details.updated_at = datetime.utcnow()
history = ProviderDetailsHistory.from_original(provider_details)
db.session.add(provider_details)
db.session.add(history)