Rajout d'un champ modifiable pour préciser les droits de vote

This commit is contained in:
Tom Hubrecht 2021-04-14 01:59:23 +02:00
parent d7d0717940
commit ee6be9983e
6 changed files with 53 additions and 1 deletions

View file

@ -22,7 +22,18 @@ class ElectionForm(forms.ModelForm):
class Meta: class Meta:
model = Election model = Election
fields = ["name", "description", "restricted", "start_date", "end_date"] fields = [
"name",
"description",
"vote_restrictions",
"restricted",
"start_date",
"end_date",
]
widgets = {
"description": forms.Textarea(attrs={"rows": 4}),
"vote_restrictions": forms.Textarea(attrs={"rows": 4}),
}
class UploadVotersForm(forms.Form): class UploadVotersForm(forms.Form):

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2021-04-13 23:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("elections", "0020_alter_user_first_name"),
]
operations = [
migrations.AddField(
model_name="election",
name="vote_restrictions",
field=models.TextField(blank=True, verbose_name="conditions de vote"),
),
]

View file

@ -32,6 +32,8 @@ class Election(models.Model):
start_date = models.DateTimeField(_("date et heure de début")) start_date = models.DateTimeField(_("date et heure de début"))
end_date = models.DateTimeField(_("date et heure de fin")) end_date = models.DateTimeField(_("date et heure de fin"))
vote_restrictions = models.TextField(_("conditions de vote"), blank=True)
restricted = models.BooleanField( restricted = models.BooleanField(
_("restreint le vote à une liste de personnes"), default=True _("restreint le vote à une liste de personnes"), default=True
) )

View file

@ -86,6 +86,13 @@
</div> </div>
<hr> <hr>
{# Précisions sur les modalités de vote #}
{% if election.vote_restrictions %}
<div class="message is-warning">
<div class="message-body">{{ election.vote_restrictions|linebreaksbr }}</div>
</div>
{% endif %}
{# Indications de connexion #} {# Indications de connexion #}
{% if election.start_date < current_time and election.end_date > current_time %} {% if election.start_date < current_time and election.end_date > current_time %}
{% if can_vote %} {% if can_vote %}

View file

@ -123,6 +123,13 @@
<div class="message-body">{{ election.description|linebreaksbr }}</div> <div class="message-body">{{ election.description|linebreaksbr }}</div>
</div> </div>
{# Précisions sur les modalités de vote #}
{% if election.vote_restrictions %}
<div class="message is-warning">
<div class="message-body">{{ election.vote_restrictions|linebreaksbr }}</div>
</div>
{% endif %}
{# Liste des questions #} {# Liste des questions #}
{% for q in election.questions.all %} {% for q in election.questions.all %}
<div class="panel" id="q_{{ q.pk }}"> <div class="panel" id="q_{{ q.pk }}">

View file

@ -29,6 +29,13 @@
</div> </div>
<hr> <hr>
{# Précisions sur les modalités de vote #}
{% if election.vote_restrictions %}
<div class="message is-warning">
<div class="message-body">{{ election.vote_restrictions|linebreaksbr }}</div>
</div>
{% endif %}
<div class="message is-warning"> <div class="message is-warning">
<div class="message-body"> <div class="message-body">
{% if election.restricted %} {% if election.restricted %}