-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,191 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{% extends baseTemplate %} | ||
|
||
{% block title %}Edit Post{% endblock %} | ||
|
||
{% block content %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Edit Post</title> | ||
<!-- Bootstrap CSS --> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"> | ||
<style> | ||
.btn-purple { | ||
color: #800080; | ||
background-color: transparent; | ||
border-color: #800080; | ||
} | ||
.btn-purple.clicked { | ||
color: #fff; | ||
background-color: #800080; | ||
border-color: #800080; | ||
} | ||
.btn-purple:hover { | ||
color: #fff; | ||
background-color: #800080; | ||
border-color: #800080; | ||
} | ||
.card-header { | ||
background: none; /* Remove background */ | ||
border-bottom: none; /* Remove border */ | ||
} | ||
.btn-purple:not(.clicked):hover { | ||
background-color: #800080; | ||
border-color: #800080; | ||
color: white; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container-fluid"> | ||
<div class="row justify-content-center"> | ||
<div class="col-lg-8"> | ||
<div class="card mt-5 rounded-4 shadow"> | ||
<div class="card-header"> | ||
<h5 class="card-title" style="margin-top: 20px; margin-left: 20px;"><strong>Edit Post</strong></h5> | ||
</div> | ||
<div class="card-body" style="margin-left: 20px; margin-right: 20px;"> | ||
<form method="post" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
{% if form.errors %} | ||
<div class="alert alert-danger" role="alert"> | ||
Please correct the errors below: | ||
<ul> | ||
{% for error in form.non_field_errors %} | ||
<li>{{ error }}</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% endif %} | ||
<div class="mb-3"> | ||
<label class="form-label">Label:</label> | ||
<div class="btn-group" role="group" aria-label="Post Type"> | ||
{% for value, label in form.label.field.choices %} | ||
<input type="radio" class="btn-check" name="label" id="label_{{ forloop.counter }}" value="{{ value }}" autocomplete="off" {% if value == form.label.value %} checked {% endif %}> | ||
<label class="btn btn-purple" style="margin-right: 5px;" onclick="selectLabel(this)" for="label_{{ forloop.counter }}">{{ label }}</label> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="title" class="form-label">Topic:</label> | ||
{{ form.topics }} | ||
{% for error in form.topics.errors %} | ||
<div class="text-danger">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="mb-3"> | ||
<label for="title" class="form-label">Title</label> | ||
{{ form.title }} | ||
{% for error in form.title.errors %} | ||
<div class="text-danger">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="mb-3"> | ||
<label for="content" class="form-label">Content</label> | ||
{{ form.content }} | ||
{% for error in form.content.errors %} | ||
<div class="text-danger">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="mb-3"> | ||
<label for="attachment" class="form-label">Attach File (optional)</label> | ||
<input class="form-control" type="file" id="attachment" name="attachment"> | ||
{% for error in form.attachment.errors %} | ||
<div class="text-danger">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="d-flex justify-content-center"> | ||
<button type="submit" class="btn btn-primary btn-purple" style="background-color: #600E90; color: white; border-color: #600E90; margin-bottom: 20px; margin-left: 20px">Save</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Bootstrap Bundle with Popper --> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function() { | ||
// Get the selected label value | ||
var selectedLabel = "{{ form.label.value }}"; | ||
|
||
// Find the corresponding button and apply the 'clicked' class | ||
document.querySelector(`input[name="label"][value="${selectedLabel}"]`).nextElementSibling.classList.add('clicked'); | ||
document.querySelector(`input[name="label"][value="${selectedLabel}"]`).nextElementSibling.style.backgroundColor = '#600E90'; | ||
document.querySelector(`input[name="label"][value="${selectedLabel}"]`).nextElementSibling.style.color = 'white'; | ||
}); | ||
|
||
function selectLabel(button) { | ||
// Remove 'clicked' class from all buttons | ||
document.querySelectorAll('.btn-purple').forEach(btn => { | ||
btn.classList.remove('clicked'); | ||
btn.style.backgroundColor = "white"; | ||
btn.style.color='#600E90'; | ||
}); | ||
// Add 'clicked' class to selected button | ||
button.classList.add('clicked'); | ||
button.style.backgroundColor='#600E90'; | ||
button.style.color = 'white'; | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.