Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update backend_structured/routes.py
Browse files
backend_structured/routes.py
CHANGED
|
@@ -1539,7 +1539,7 @@ scans_bp = Blueprint("scans", __name__)
|
|
| 1539 |
def get_active_scans(current_user):
|
| 1540 |
# If not admin/super admin, only show their own org's scans
|
| 1541 |
query = Scan.query.filter(Scan.status.in_(['queued', 'scanning']))
|
| 1542 |
-
if current_user.role not in ('super_admin', 'support_engineer'):
|
| 1543 |
query = query.filter_by(org_id=current_user.org_id)
|
| 1544 |
|
| 1545 |
scans = query.order_by(Scan.started_at.desc()).all()
|
|
@@ -1561,14 +1561,14 @@ def terminate_scan(current_user, scan_id):
|
|
| 1561 |
if not scan:
|
| 1562 |
return jsonify({'message': 'Scan not found'}), 404
|
| 1563 |
|
| 1564 |
-
if current_user.role not in ('super_admin', 'support_engineer') and scan.org_id != current_user.org_id:
|
| 1565 |
return jsonify({'message': 'Permission denied'}), 403
|
| 1566 |
|
| 1567 |
scan.status = 'terminated'
|
| 1568 |
db.session.commit()
|
| 1569 |
|
| 1570 |
# Log the action
|
| 1571 |
-
if current_user.role in ('super_admin', 'support_engineer'):
|
| 1572 |
log = AuditLog(admin_id=current_user.id, action=f"Terminated scan {scan_id}", target_id=scan.org_id)
|
| 1573 |
db.session.add(log)
|
| 1574 |
db.session.commit()
|
|
|
|
| 1539 |
def get_active_scans(current_user):
|
| 1540 |
# If not admin/super admin, only show their own org's scans
|
| 1541 |
query = Scan.query.filter(Scan.status.in_(['queued', 'scanning']))
|
| 1542 |
+
if current_user.role not in ('super_admin', 'admin', 'support_engineer'):
|
| 1543 |
query = query.filter_by(org_id=current_user.org_id)
|
| 1544 |
|
| 1545 |
scans = query.order_by(Scan.started_at.desc()).all()
|
|
|
|
| 1561 |
if not scan:
|
| 1562 |
return jsonify({'message': 'Scan not found'}), 404
|
| 1563 |
|
| 1564 |
+
if current_user.role not in ('super_admin', 'admin', 'support_engineer') and scan.org_id != current_user.org_id:
|
| 1565 |
return jsonify({'message': 'Permission denied'}), 403
|
| 1566 |
|
| 1567 |
scan.status = 'terminated'
|
| 1568 |
db.session.commit()
|
| 1569 |
|
| 1570 |
# Log the action
|
| 1571 |
+
if current_user.role in ('super_admin', 'admin', 'support_engineer'):
|
| 1572 |
log = AuditLog(admin_id=current_user.id, action=f"Terminated scan {scan_id}", target_id=scan.org_id)
|
| 1573 |
db.session.add(log)
|
| 1574 |
db.session.commit()
|