fix: Add flag_modified for JSONB workflow_history persistence
SQLAlchemy doesn't detect in-place changes to JSONB columns. Using flag_modified() and creating new list ensures changes are saved. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
03c429dcf9
commit
f71b12eeba
@ -11,6 +11,7 @@ from datetime import datetime
|
||||
|
||||
from flask import render_template, request, redirect, url_for, flash, jsonify
|
||||
from flask_login import login_required, current_user
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
|
||||
from . import bp
|
||||
from database import (
|
||||
@ -452,7 +453,8 @@ def admin_membership_propose_changes(app_id):
|
||||
'comment': comment
|
||||
}
|
||||
})
|
||||
application.workflow_history = history
|
||||
application.workflow_history = list(history) # Create new list for SQLAlchemy detection
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
# Create notification for user
|
||||
notification = UserNotification(
|
||||
|
||||
@ -10,6 +10,7 @@ from datetime import datetime
|
||||
|
||||
from flask import render_template, request, redirect, url_for, flash, jsonify
|
||||
from flask_login import login_required, current_user
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
|
||||
from . import bp
|
||||
from database import SessionLocal, MembershipApplication, CompanyDataRequest, Company, UserNotification, User
|
||||
@ -362,7 +363,8 @@ def accept_changes(app_id):
|
||||
'comment': application.proposed_changes_comment
|
||||
}
|
||||
})
|
||||
application.workflow_history = history
|
||||
application.workflow_history = list(history) # Create new list for SQLAlchemy change detection
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
# Update status - back to under_review for final approval
|
||||
application.status = 'under_review'
|
||||
@ -455,7 +457,8 @@ def reject_changes(app_id):
|
||||
'original_comment': application.proposed_changes_comment
|
||||
}
|
||||
})
|
||||
application.workflow_history = history
|
||||
application.workflow_history = list(history) # Create new list for SQLAlchemy change detection
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
# Clear proposed changes - keep original data
|
||||
application.proposed_changes = None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user