153 lines
6.0 KiB
HTML
153 lines
6.0 KiB
HTML
{% extends "admin/base_site.html" %}
|
|
{% block page_title %}{{ title }}{% endblock %}
|
|
{% load static %}
|
|
{% block extrastyle %}
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
|
|
rel="stylesheet" />
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
|
|
rel="stylesheet" />
|
|
<style>
|
|
.required-field::after {
|
|
content: "*";
|
|
color: red;
|
|
margin-left: 4px;
|
|
}
|
|
|
|
.help-text {
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.page-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 1rem;
|
|
background-color: #f8f9fa;
|
|
border-bottom: 1px solid #dee2e6;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.page-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
margin: 0;
|
|
}
|
|
|
|
.card {
|
|
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
{% block content %}
|
|
<div class="page-header">
|
|
<h1 class="page-title">
|
|
<i class="nav-icon fas fa-edit"></i>
|
|
Edit Course
|
|
</h1>
|
|
<a href="{% url 'manage_course' %}" class="btn btn-primary">
|
|
<i class="fas fa-list"></i> Back to Courses
|
|
</a>
|
|
</div>
|
|
<div class="container py-4">
|
|
<div class="card">
|
|
<div class="card-header bg-primary text-white">
|
|
<h2 class="h4 mb-0">Edit Course: {{ course.name }}</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post" class="needs-validation" novalidate>
|
|
{% csrf_token %}
|
|
<!-- Course Name -->
|
|
<div class="form-group mb-4">
|
|
<label for="name" class="required-field">Course Name</label>
|
|
<input type="text"
|
|
class="form-control"
|
|
id="name"
|
|
name="name"
|
|
value="{{ course.name }}"
|
|
placeholder="Enter course name"
|
|
required />
|
|
<div class="help-text">Course name must be unique</div>
|
|
<div class="invalid-feedback">Please enter a course name</div>
|
|
</div>
|
|
<!-- Course Type -->
|
|
<div class="form-group mb-4">
|
|
<label for="course_type" class="required-field">Course Type</label>
|
|
<select class="form-control" id="course_type" name="course_type" required>
|
|
<option value="">Select Course Type</option>
|
|
<option value="semester"
|
|
{% if course.course_type == "semester" %}selected{% endif %}>
|
|
Semester-based
|
|
</option>
|
|
<option value="year" {% if course.course_type == "year" %}selected{% endif %}>Year-based</option>
|
|
</select>
|
|
<div class="invalid-feedback">Please select a course type</div>
|
|
</div>
|
|
<!-- Duration -->
|
|
<div class="form-group mb-4">
|
|
<label for="duration" class="required-field">Duration</label>
|
|
<input type="number"
|
|
class="form-control"
|
|
id="duration"
|
|
name="duration"
|
|
value="{{ course.duration }}"
|
|
placeholder="Enter duration in months"
|
|
min="1"
|
|
required />
|
|
<div class="help-text">Specify the duration in months</div>
|
|
<div class="invalid-feedback">Please enter a valid duration (minimum 1 month)</div>
|
|
</div>
|
|
{% if messages %}
|
|
<div class="mb-4">
|
|
{% for message in messages %}
|
|
<div class="alert alert-{{ message.tags }} alert-dismissible fade show">
|
|
{{ message }}
|
|
<button type="button"
|
|
class="btn-close"
|
|
data-bs-dismiss="alert"
|
|
aria-label="Close"></button>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
<div class="d-flex justify-content-end gap-2">
|
|
<a href="{% url 'manage_course' %}" class="btn btn-secondary">
|
|
<i class="fas fa-times"></i> Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fas fa-save"></i> Update Course
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% block extrajs %}
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
// Form validation
|
|
(function () {
|
|
"use strict";
|
|
|
|
const forms = document.querySelectorAll(".needs-validation");
|
|
|
|
Array.from(forms).forEach((form) => {
|
|
form.addEventListener(
|
|
"submit",
|
|
(event) => {
|
|
if (!form.checkValidity()) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}
|
|
form.classList.add("was-validated");
|
|
},
|
|
false,
|
|
);
|
|
});
|
|
})();
|
|
</script>
|
|
{% endblock %}
|
|
{% endblock %}
|