mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-17 04:58:50 -04:00
add updated_at to provider_details
it's set to utcnow from dao_update_provider_details
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import asc
|
||||
from app.dao.dao_utils import transactional
|
||||
from app.models import ProviderDetails, ProviderDetailsHistory
|
||||
@@ -21,6 +23,7 @@ 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)
|
||||
|
||||
@@ -368,6 +368,7 @@ class ProviderDetails(db.Model):
|
||||
notification_type = db.Column(notification_types, nullable=False)
|
||||
active = db.Column(db.Boolean, default=False, nullable=False)
|
||||
version = db.Column(db.Integer, default=1, nullable=False)
|
||||
updated_at = db.Column(db.DateTime, nullable=True, onupdate=datetime.datetime.utcnow)
|
||||
|
||||
|
||||
class ProviderDetailsHistory(db.Model, HistoryModel):
|
||||
@@ -380,6 +381,7 @@ class ProviderDetailsHistory(db.Model, HistoryModel):
|
||||
notification_type = db.Column(notification_types, nullable=False)
|
||||
active = db.Column(db.Boolean, nullable=False)
|
||||
version = db.Column(db.Integer, primary_key=True, nullable=False)
|
||||
updated_at = db.Column(db.DateTime, nullable=True, onupdate=datetime.datetime.utcnow)
|
||||
|
||||
|
||||
JOB_STATUS_PENDING = 'pending'
|
||||
|
||||
@@ -37,7 +37,7 @@ def update_provider_details(provider_details_id):
|
||||
current_data.update(request.get_json())
|
||||
update_dict = provider_details_schema.load(current_data).data
|
||||
|
||||
invalid_keys = {'identifier', 'version'} & set(key for key in request.get_json().keys())
|
||||
invalid_keys = {'identifier', 'version', 'updated_at'} & set(key for key in request.get_json().keys())
|
||||
if invalid_keys:
|
||||
message = "Not permitted to be updated"
|
||||
errors = {key: [message] for key in invalid_keys}
|
||||
|
||||
Reference in New Issue
Block a user