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 staticfiles %}
|
||||||
{% load bulma_utils %}
|
{% load bulma_utils %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -18,6 +19,20 @@
|
||||||
<script src="{% static 'vendor/jquery/jquery-3.5.1.min.js' %}"></script>
|
<script src="{% static 'vendor/jquery/jquery-3.5.1.min.js' %}"></script>
|
||||||
{# <script src="{% static 'elections/js/main.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 %}
|
{% block extra_head %}{% endblock extra_head %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -35,29 +50,38 @@
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
{% block layout %}
|
{% block layout %}
|
||||||
<div class="columns is-centered">
|
<div class="main-content">
|
||||||
<div class="column is-two-thirds">
|
<div class="columns is-centered">
|
||||||
<section class="section">
|
<div class="column is-two-thirds">
|
||||||
|
<section class="section">
|
||||||
|
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
<div class="notification is-{{ message.level_tag|bulma_message_tag }}">
|
<div class="notification is-{{ message.level_tag|bulma_message_tag }} is-light">
|
||||||
{% if 'safe' in message.tags %}
|
{% if 'safe' in message.tags %}
|
||||||
{{ message|safe }}
|
{{ message|safe }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ message }}
|
{{ message }}
|
||||||
|
{% endif %}
|
||||||
|
<button class="delete"></button>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button class="delete"></button>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% block content %}
|
<div class="box">
|
||||||
{% endblock content %}
|
{% block content %}
|
||||||
</section>
|
{% endblock content %}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock layout %}
|
{% 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>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h1 class="title">{{ election.name }}</h1>
|
<h1 class="title">{{ election.name }}</h1>
|
||||||
|
<hr>
|
||||||
|
|
||||||
<div class="message is-info">
|
<div class="message is-info">
|
||||||
<p class="message-body">{{ election.description }}</p>
|
<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.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.db.models import Count, Prefetch
|
from django.db.models import Count, Prefetch
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
|
@ -47,7 +48,7 @@ class ElectionView(DetailView):
|
||||||
return super().get_queryset().filter(archived=False)
|
return super().get_queryset().filter(archived=False)
|
||||||
|
|
||||||
|
|
||||||
class VoteView(DetailView):
|
class VoteView(SuccessMessageMixin, DetailView):
|
||||||
model = Question
|
model = Question
|
||||||
template_name = "elections/vote.html"
|
template_name = "elections/vote.html"
|
||||||
|
|
||||||
|
@ -74,6 +75,8 @@ class VoteView(DetailView):
|
||||||
for v in vote_form:
|
for v in vote_form:
|
||||||
v.record_vote(self.request.user)
|
v.record_vote(self.request.user)
|
||||||
|
|
||||||
|
messages.success(self.request, _("Votre vote a bien été enregistré !"))
|
||||||
|
|
||||||
return HttpResponseRedirect(
|
return HttpResponseRedirect(
|
||||||
reverse("election.view", args=[self.object.election.pk])
|
reverse("election.view", args=[self.object.election.pk])
|
||||||
+ f"#q_{self.object.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;
|
background-color: #fafafa;
|
||||||
padding: 3rem 1.5rem 6rem; }
|
padding: 3rem 1.5rem 6rem; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
min-height: 100vh;
|
||||||
|
flex-direction: column; }
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1; }
|
||||||
|
|
||||||
/*# sourceMappingURL=main.css.map */
|
/*# 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"
|
$family-secondary: "Carter One"
|
||||||
|
|
||||||
@import "../bulma/bulma.sass"
|
@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