feat(membership): record workflow history for all status changes
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Added workflow_history entries to all membership application status transitions: - submitted (user submits form) — blueprints/membership/routes.py - start_review, approved, rejected, changes_requested — blueprints/admin/routes_membership.py Each entry includes event name, action_label (Polish display text), timestamp, user_id/user_name, and relevant details (comment, member_number, category, IP). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cd26c11ec8
commit
3931b1466c
@ -561,6 +561,27 @@ def admin_membership_approve(app_id):
|
||||
)
|
||||
db.add(user_company)
|
||||
|
||||
# Add to workflow history
|
||||
history = application.workflow_history or []
|
||||
history_details = {
|
||||
'member_number': application.member_number,
|
||||
'company_id': company.id,
|
||||
}
|
||||
if data.get('category_id'):
|
||||
history_details['category_id'] = data['category_id']
|
||||
if data.get('comment'):
|
||||
history_details['comment'] = data['comment']
|
||||
history.append({
|
||||
'event': 'approved',
|
||||
'action_label': 'Deklaracja zatwierdzona',
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'user_id': current_user.id,
|
||||
'user_name': current_user.name or current_user.email,
|
||||
'details': history_details
|
||||
})
|
||||
application.workflow_history = list(history)
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
db.commit()
|
||||
|
||||
logger.info(
|
||||
@ -628,6 +649,19 @@ def admin_membership_reject(app_id):
|
||||
application.reviewed_by_id = current_user.id
|
||||
application.review_comment = comment
|
||||
|
||||
# Add to workflow history
|
||||
history = application.workflow_history or []
|
||||
history.append({
|
||||
'event': 'rejected',
|
||||
'action_label': 'Deklaracja odrzucona',
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'user_id': current_user.id,
|
||||
'user_name': current_user.name or current_user.email,
|
||||
'details': {'comment': comment}
|
||||
})
|
||||
application.workflow_history = list(history)
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
db.commit()
|
||||
|
||||
logger.info(f"Membership application {app_id} rejected by {current_user.email}: {comment}")
|
||||
@ -672,6 +706,19 @@ def admin_membership_request_changes(app_id):
|
||||
application.reviewed_by_id = current_user.id
|
||||
application.review_comment = comment
|
||||
|
||||
# Add to workflow history
|
||||
history = application.workflow_history or []
|
||||
history.append({
|
||||
'event': 'changes_requested',
|
||||
'action_label': 'Poproszono o poprawki',
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'user_id': current_user.id,
|
||||
'user_name': current_user.name or current_user.email,
|
||||
'details': {'comment': comment}
|
||||
})
|
||||
application.workflow_history = list(history)
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
db.commit()
|
||||
|
||||
logger.info(f"Changes requested for application {app_id} by {current_user.email}: {comment}")
|
||||
@ -704,6 +751,20 @@ def admin_membership_start_review(app_id):
|
||||
|
||||
application.status = 'under_review'
|
||||
application.reviewed_by_id = current_user.id
|
||||
|
||||
# Add to workflow history
|
||||
history = application.workflow_history or []
|
||||
history.append({
|
||||
'event': 'start_review',
|
||||
'action_label': 'Rozpoczęto rozpatrywanie',
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'user_id': current_user.id,
|
||||
'user_name': current_user.name or current_user.email,
|
||||
'details': {}
|
||||
})
|
||||
application.workflow_history = list(history)
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
db.commit()
|
||||
|
||||
return jsonify({'success': True})
|
||||
|
||||
@ -191,6 +191,24 @@ def apply_step(step):
|
||||
# Submit application
|
||||
application.status = 'submitted'
|
||||
application.submitted_at = datetime.now()
|
||||
|
||||
# Add to workflow history
|
||||
history = application.workflow_history or []
|
||||
history.append({
|
||||
'event': 'submitted',
|
||||
'action_label': 'Deklaracja złożona',
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'user_id': current_user.id,
|
||||
'user_name': current_user.name or current_user.email,
|
||||
'details': {
|
||||
'company_name': application.company_name,
|
||||
'nip': application.nip,
|
||||
'ip_address': request.remote_addr
|
||||
}
|
||||
})
|
||||
application.workflow_history = list(history)
|
||||
flag_modified(application, 'workflow_history')
|
||||
|
||||
db.commit()
|
||||
|
||||
# Wyślij notyfikacje do administratorów i kierowników biura
|
||||
|
||||
Loading…
Reference in New Issue
Block a user