557 lines
30 KiB
HTML
557 lines
30 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Risk Assessment{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'quality:dashboard' %}">Quality</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'quality:risk_assessment_list' %}">Risk Assessments</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'quality:risk_assessment_detail' object.pk %}">{{ object.title|truncatechars:30 }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">Delete Risk Assessment</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<a href="{% url 'quality:risk_assessment_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-arrow-left me-2"></i>Back to Assessment
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-xl-8">
|
|
<div class="card">
|
|
<div class="card-header bg-danger text-white">
|
|
<h4 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Confirm Risk Assessment Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<h5 class="alert-heading">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Are you sure you want to delete this risk assessment?
|
|
</h5>
|
|
<p class="mb-0">
|
|
This action cannot be undone. The risk assessment and all associated data will be permanently removed from the system.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Assessment Details -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-shield-alt me-2"></i>Assessment Information
|
|
</h6>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Title:</strong> {{ object.title }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Assessment ID:</strong>
|
|
<span class="badge bg-primary">{{ object.assessment_id }}</span>
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Category:</strong> {{ object.get_risk_category_display }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Department:</strong> {{ object.department.name|default:"All Departments" }}
|
|
</div>
|
|
<div>
|
|
<strong>Assessor:</strong> {{ object.assessor.get_full_name }}
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Priority:</strong>
|
|
<span class="badge bg-{% if object.priority == 'critical' %}danger{% elif object.priority == 'high' %}warning{% elif object.priority == 'medium' %}info{% else %}secondary{% endif %}">
|
|
{{ object.get_priority_display }}
|
|
</span>
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Risk Score:</strong>
|
|
<span class="badge bg-{% if object.overall_risk_score >= 15 %}danger{% elif object.overall_risk_score >= 10 %}warning{% elif object.overall_risk_score >= 5 %}info{% else %}success{% endif %} fs-6">
|
|
{{ object.overall_risk_score|default:0 }}
|
|
</span>
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Risk Level:</strong>
|
|
<span class="badge bg-{% if object.risk_level == 'very_high' %}danger{% elif object.risk_level == 'high' %}warning{% elif object.risk_level == 'medium' %}info{% elif object.risk_level == 'low' %}success{% else %}secondary{% endif %}">
|
|
{{ object.get_risk_level_display }}
|
|
</span>
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Status:</strong>
|
|
<span class="badge bg-{% if object.status == 'draft' %}secondary{% elif object.status == 'in_review' %}warning{% elif object.status == 'approved' %}success{% elif object.status == 'implemented' %}info{% else %}danger{% endif %}">
|
|
{{ object.get_status_display }}
|
|
</span>
|
|
</div>
|
|
<div>
|
|
<strong>Assessment Date:</strong> {{ object.assessment_date|date:"M d, Y" }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Risk Description -->
|
|
{% if object.description %}
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-file-alt me-2"></i>Risk Description
|
|
</h6>
|
|
<div class="alert alert-info">
|
|
{{ object.description|linebreaks }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Critical Assessment Warning -->
|
|
{% if object.priority in 'high,critical' or object.risk_level in 'high,very_high' %}
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card border-danger">
|
|
<div class="card-header bg-danger text-white">
|
|
<h6 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Critical Risk Assessment Warning
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-danger">
|
|
<strong>Warning:</strong> This is a {{ object.get_priority_display|lower }} priority risk assessment
|
|
with {{ object.get_risk_level_display|lower }} risk level. Deleting this assessment may impact
|
|
organizational risk management and compliance.
|
|
</div>
|
|
|
|
{% if object.status == 'approved' %}
|
|
<div class="alert alert-warning">
|
|
<strong>Approved Assessment:</strong> This assessment has been approved and may be part of
|
|
active risk management processes. Removing it could affect ongoing mitigation efforts.
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.status == 'implemented' %}
|
|
<div class="alert alert-info">
|
|
<strong>Implemented Assessment:</strong> This assessment has been implemented and mitigation
|
|
strategies may be in place. Consider archiving instead of deleting.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Related Items Impact -->
|
|
{% if related_incidents or related_audits or related_corrective_actions %}
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card border-warning">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h6 class="card-title mb-0">
|
|
<i class="fas fa-link me-2"></i>
|
|
Related Items Impact
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<strong>Impact Warning:</strong> This risk assessment is linked to other quality management items.
|
|
Deleting it may affect the integrity of related records.
|
|
</div>
|
|
|
|
{% if related_incidents %}
|
|
<div class="mb-3">
|
|
<h6>Related Incidents ({{ related_incidents|length }})</h6>
|
|
{% for incident in related_incidents %}
|
|
<div class="mb-1">
|
|
<a href="{% url 'quality:incident_detail' incident.pk %}" class="text-decoration-none">
|
|
{{ incident.incident_id }} - {{ incident.title|truncatechars:50 }}
|
|
</a>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if related_audits %}
|
|
<div class="mb-3">
|
|
<h6>Related Audits ({{ related_audits|length }})</h6>
|
|
{% for audit in related_audits %}
|
|
<div class="mb-1">
|
|
<a href="{% url 'quality:audit_detail' audit.pk %}" class="text-decoration-none">
|
|
{{ audit.title|truncatechars:50 }}
|
|
</a>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if related_corrective_actions %}
|
|
<div class="mb-3">
|
|
<h6>Related Corrective Actions ({{ related_corrective_actions|length }})</h6>
|
|
{% for action in related_corrective_actions %}
|
|
<div class="mb-1">
|
|
<a href="{% url 'quality:corrective_action_detail' action.pk %}" class="text-decoration-none">
|
|
{{ action.title|truncatechars:50 }}
|
|
</a>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Deletion Form -->
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<div class="mb-3">
|
|
<label for="deletion_reason" class="form-label">
|
|
<strong>Reason for Deletion *</strong>
|
|
</label>
|
|
<select class="form-select" id="deletion_reason" name="deletion_reason" required>
|
|
<option value="">Select a reason</option>
|
|
<option value="duplicate_assessment">Duplicate Assessment</option>
|
|
<option value="incorrect_information">Incorrect Information</option>
|
|
<option value="outdated_assessment">Outdated Assessment</option>
|
|
<option value="risk_no_longer_applicable">Risk No Longer Applicable</option>
|
|
<option value="merged_with_other">Merged with Other Assessment</option>
|
|
<option value="superseded_by_new">Superseded by New Assessment</option>
|
|
<option value="regulatory_change">Regulatory Change</option>
|
|
<option value="organizational_change">Organizational Change</option>
|
|
<option value="system_cleanup">System Cleanup</option>
|
|
<option value="other">Other</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="deletion_notes" class="form-label">
|
|
<strong>Additional Notes</strong>
|
|
</label>
|
|
<textarea class="form-control"
|
|
id="deletion_notes"
|
|
name="deletion_notes"
|
|
rows="3"
|
|
placeholder="Provide additional details about why this risk assessment is being deleted..."></textarea>
|
|
<div class="form-text">
|
|
These notes will be recorded for audit purposes and quality management review.
|
|
</div>
|
|
</div>
|
|
|
|
{% if object.priority in 'high,critical' or object.risk_level in 'high,very_high' %}
|
|
<div class="mb-3">
|
|
<label for="management_approval" class="form-label">
|
|
<strong>Management Approval *</strong>
|
|
</label>
|
|
<select class="form-select" id="management_approval" name="management_approval" required>
|
|
<option value="">Select approval status</option>
|
|
<option value="quality_manager_approved">Quality Manager Approved</option>
|
|
<option value="department_head_approved">Department Head Approved</option>
|
|
<option value="risk_committee_approved">Risk Committee Approved</option>
|
|
<option value="executive_approved">Executive Approved</option>
|
|
<option value="emergency_deletion">Emergency Deletion</option>
|
|
</select>
|
|
<div class="form-text">
|
|
High-risk assessments require management approval for deletion.
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="mb-3">
|
|
<label for="replacement_assessment" class="form-label">
|
|
<strong>Replacement Assessment</strong>
|
|
</label>
|
|
<select class="form-select" id="replacement_assessment" name="replacement_assessment">
|
|
<option value="">No replacement</option>
|
|
{% for assessment in available_assessments %}
|
|
<option value="{{ assessment.pk }}">
|
|
{{ assessment.assessment_id }} - {{ assessment.title|truncatechars:50 }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
<div class="form-text">
|
|
If this assessment is being replaced by another, select it here.
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="confirm_deletion"
|
|
name="confirm_deletion"
|
|
required>
|
|
<label class="form-check-label" for="confirm_deletion">
|
|
I understand that this action cannot be undone and confirm the deletion of this risk assessment.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="notify_stakeholders"
|
|
name="notify_stakeholders">
|
|
<label class="form-check-label" for="notify_stakeholders">
|
|
Notify relevant stakeholders about this assessment deletion.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="archive_data"
|
|
name="archive_data"
|
|
checked>
|
|
<label class="form-check-label" for="archive_data">
|
|
Archive assessment data for audit trail (recommended).
|
|
</label>
|
|
</div>
|
|
|
|
{% if related_incidents or related_audits or related_corrective_actions %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="update_related_items"
|
|
name="update_related_items">
|
|
<label class="form-check-label" for="update_related_items">
|
|
Update related items to remove references to this assessment.
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.status == 'implemented' %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="review_mitigation_strategies"
|
|
name="review_mitigation_strategies">
|
|
<label class="form-check-label" for="review_mitigation_strategies">
|
|
Review and maintain existing mitigation strategies independently.
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="alert alert-info">
|
|
<h6 class="alert-heading">
|
|
<i class="fas fa-info-circle me-2"></i>What happens when you delete this risk assessment?
|
|
</h6>
|
|
<ul class="mb-0">
|
|
<li>The risk assessment record will be permanently removed from the system</li>
|
|
<li>All associated risk factors and mitigation strategies will be deleted</li>
|
|
<li>Historical assessment data will be archived (if selected)</li>
|
|
<li>Related items may lose their risk assessment references</li>
|
|
<li>This action will be logged in the audit trail</li>
|
|
<li>Quality management reports may be affected</li>
|
|
{% if object.priority in 'high,critical' %}
|
|
<li>High-priority risk deletion may require additional management review</li>
|
|
<li>Risk management processes may need to be updated</li>
|
|
{% endif %}
|
|
{% if object.status == 'implemented' %}
|
|
<li>Implemented mitigation strategies may need independent tracking</li>
|
|
<li>Ongoing risk monitoring may be affected</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="{% url 'quality:risk_assessment_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-times me-2"></i>Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-danger" onclick="return confirmDeletion()">
|
|
<i class="fas fa-trash me-2"></i>Delete Assessment
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alternative Actions -->
|
|
<div class="card mt-4">
|
|
<div class="card-header bg-info text-white">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-lightbulb me-2"></i>
|
|
Consider These Alternatives
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-info">
|
|
<strong>Before deleting,</strong> consider these alternative actions:
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-archive text-secondary me-2"></i>Archive Assessment
|
|
</h6>
|
|
<p class="card-text small">
|
|
Archive the assessment instead of deleting to preserve historical data while removing it from active use.
|
|
</p>
|
|
<a href="{% url 'quality:risk_assessment_form' object.pk %}?action=archive" class="btn btn-sm btn-outline-secondary">
|
|
Archive Instead
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-edit text-primary me-2"></i>Update Assessment
|
|
</h6>
|
|
<p class="card-text small">
|
|
Update the assessment with current information instead of deleting it completely.
|
|
</p>
|
|
<a href="{% url 'quality:risk_assessment_form' object.pk %}" class="btn btn-sm btn-outline-primary">
|
|
Edit Assessment
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-3">
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-copy text-info me-2"></i>Create New Version
|
|
</h6>
|
|
<p class="card-text small">
|
|
Create a new version of this assessment with updated information while preserving the original.
|
|
</p>
|
|
<a href="{% url 'quality:risk_assessment_form' %}?duplicate={{ object.pk }}" class="btn btn-sm btn-outline-info">
|
|
Create New Version
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-merge text-success me-2"></i>Merge with Another
|
|
</h6>
|
|
<p class="card-text small">
|
|
Merge this assessment with another similar assessment to consolidate risk management efforts.
|
|
</p>
|
|
<button type="button" class="btn btn-sm btn-outline-success" onclick="mergeAssessment()">
|
|
Merge Assessment
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- System Information -->
|
|
<div class="card mt-4">
|
|
<div class="card-header">
|
|
<h5 class="card-title">
|
|
<i class="fas fa-info-circle me-2"></i>
|
|
System Information
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6>Assessment Details</h6>
|
|
<ul class="list-unstyled">
|
|
<li><strong>Assessment ID:</strong> {{ object.pk }}</li>
|
|
<li><strong>Created:</strong> {{ object.created_at|date:"M d, Y g:i A" }}</li>
|
|
<li><strong>Last Updated:</strong> {{ object.updated_at|date:"M d, Y g:i A" }}</li>
|
|
<li><strong>Created By:</strong> {{ object.created_by.get_full_name|default:"System" }}</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6>Risk Information</h6>
|
|
<ul class="list-unstyled">
|
|
<li><strong>Risk Factors:</strong> {{ risk_factor_count|default:0 }}</li>
|
|
<li><strong>Review Date:</strong> {{ object.review_date|date:"M d, Y"|default:"Not scheduled" }}</li>
|
|
<li><strong>Version:</strong> {{ object.version|default:"1.0" }}</li>
|
|
<li><strong>Confidential:</strong> {{ object.is_confidential|yesno:"Yes,No" }}</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function confirmDeletion() {
|
|
const reason = document.getElementById('deletion_reason').value;
|
|
const confirmed = document.getElementById('confirm_deletion').checked;
|
|
|
|
if (!reason) {
|
|
alert('Please select a reason for deletion.');
|
|
return false;
|
|
}
|
|
|
|
if (!confirmed) {
|
|
alert('Please confirm that you understand this action cannot be undone.');
|
|
return false;
|
|
}
|
|
|
|
{% if object.priority in 'high,critical' or object.risk_level in 'high,very_high' %}
|
|
const managementApproval = document.getElementById('management_approval').value;
|
|
if (!managementApproval) {
|
|
alert('Management approval is required for deleting high-risk assessments.');
|
|
return false;
|
|
}
|
|
{% endif %}
|
|
|
|
const title = "{{ object.title }}";
|
|
const priority = "{{ object.get_priority_display }}";
|
|
const riskLevel = "{{ object.get_risk_level_display }}";
|
|
|
|
const message = `Are you absolutely sure you want to delete this risk assessment?\n\nTitle: ${title}\nPriority: ${priority}\nRisk Level: ${riskLevel}\n\nThis action cannot be undone and may affect organizational risk management.`;
|
|
|
|
return confirm(message);
|
|
}
|
|
|
|
function mergeAssessment() {
|
|
alert('Merge assessment functionality would be implemented here.');
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Auto-focus on deletion reason
|
|
document.getElementById('deletion_reason').focus();
|
|
|
|
// Show/hide additional notes based on reason
|
|
const reasonSelect = document.getElementById('deletion_reason');
|
|
const notesTextarea = document.getElementById('deletion_notes');
|
|
|
|
reasonSelect.addEventListener('change', function() {
|
|
if (this.value === 'other') {
|
|
notesTextarea.required = true;
|
|
notesTextarea.placeholder = 'Please specify the reason for deletion...';
|
|
} else {
|
|
notesTextarea.required = false;
|
|
notesTextarea.placeholder = 'Provide additional details about why this risk assessment is being deleted...';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|