Can delete notifications, add confirmation after a vote
This commit is contained in:
parent
01c164bc99
commit
ac1896d366
6 changed files with 64 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
|||
{% load staticfiles %}
|
||||
{% load bulma_utils %}
|
||||
{% load i18n %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -18,6 +19,20 @@
|
|||
<script src="{% static 'vendor/jquery/jquery-3.5.1.min.js' %}"></script>
|
||||
{# <script src="{% static 'elections/js/main.js' %}"></script> #}
|
||||
|
||||
<!-- Delete notification -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
(document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {
|
||||
var $notification = $delete.parentNode;
|
||||
|
||||
$delete.addEventListener('click', () => {
|
||||
$notification.parentNode.removeChild($notification);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{% block extra_head %}{% endblock extra_head %}
|
||||
</head>
|
||||
|
||||
|
@ -35,29 +50,38 @@
|
|||
</div>
|
||||
</nav>
|
||||
{% block layout %}
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-two-thirds">
|
||||
<section class="section">
|
||||
<div class="main-content">
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-two-thirds">
|
||||
<section class="section">
|
||||
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="notification is-{{ message.level_tag|bulma_message_tag }}">
|
||||
{% if 'safe' in message.tags %}
|
||||
{{ message|safe }}
|
||||
{% else %}
|
||||
{{ message }}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="notification is-{{ message.level_tag|bulma_message_tag }} is-light">
|
||||
{% if 'safe' in message.tags %}
|
||||
{{ message|safe }}
|
||||
{% else %}
|
||||
{{ message }}
|
||||
{% endif %}
|
||||
<button class="delete"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<button class="delete"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</section>
|
||||
<div class="box">
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock layout %}
|
||||
<footer class="footer">
|
||||
<p class="has-text-centered">
|
||||
{% blocktrans %}Développé par <a class="tag is-light is-danger" href="https://www.eleves.ens.fr/kde">KDEns</a>. Pour tout problème, contacter <span class="tag is-info is-light">klub-dev [at] ens [dot] fr</span>.{% endblocktrans %}
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
{% block content %}
|
||||
|
||||
<h1 class="title">{{ election.name }}</h1>
|
||||
<hr>
|
||||
|
||||
<div class="message is-info">
|
||||
<p class="message-body">{{ election.description }}</p>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.contrib import messages
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.db.models import Count, Prefetch
|
||||
from django.http import HttpResponseRedirect
|
||||
|
@ -47,7 +48,7 @@ class ElectionView(DetailView):
|
|||
return super().get_queryset().filter(archived=False)
|
||||
|
||||
|
||||
class VoteView(DetailView):
|
||||
class VoteView(SuccessMessageMixin, DetailView):
|
||||
model = Question
|
||||
template_name = "elections/vote.html"
|
||||
|
||||
|
@ -74,6 +75,8 @@ class VoteView(DetailView):
|
|||
for v in vote_form:
|
||||
v.record_vote(self.request.user)
|
||||
|
||||
messages.success(self.request, _("Votre vote a bien été enregistré !"))
|
||||
|
||||
return HttpResponseRedirect(
|
||||
reverse("election.view", args=[self.object.election.pk])
|
||||
+ f"#q_{self.object.pk}"
|
||||
|
|
|
@ -7554,4 +7554,12 @@ a.has-text-danger-dark:hover, a.has-text-danger-dark:focus {
|
|||
background-color: #fafafa;
|
||||
padding: 3rem 1.5rem 6rem; }
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
flex-direction: column; }
|
||||
|
||||
.main-content {
|
||||
flex: 1; }
|
||||
|
||||
/*# sourceMappingURL=main.css.map */
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,3 +20,12 @@ $body-background-color: hsl(0, 0%, 86%)
|
|||
$family-secondary: "Carter One"
|
||||
|
||||
@import "../bulma/bulma.sass"
|
||||
|
||||
// Full page layout
|
||||
body
|
||||
display: flex
|
||||
min-height: 100vh
|
||||
flex-direction: column
|
||||
|
||||
.main-content
|
||||
flex: 1
|
||||
|
|
Loading…
Reference in a new issue