From ee6be9983e388c144a067f6c9100870c754e68af Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Wed, 14 Apr 2021 01:59:23 +0200 Subject: [PATCH] =?UTF-8?q?Rajout=20d'un=20champ=20modifiable=20pour=20pr?= =?UTF-8?q?=C3=A9ciser=20les=20droits=20de=20vote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elections/forms.py | 13 ++++++++++++- .../0021_election_vote_restrictions.py | 18 ++++++++++++++++++ elections/models.py | 2 ++ elections/templates/elections/election.html | 7 +++++++ .../templates/elections/election_admin.html | 7 +++++++ .../templates/elections/election_voters.html | 7 +++++++ 6 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 elections/migrations/0021_election_vote_restrictions.py diff --git a/elections/forms.py b/elections/forms.py index 9682e81..e1b3b58 100644 --- a/elections/forms.py +++ b/elections/forms.py @@ -22,7 +22,18 @@ class ElectionForm(forms.ModelForm): class Meta: 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): diff --git a/elections/migrations/0021_election_vote_restrictions.py b/elections/migrations/0021_election_vote_restrictions.py new file mode 100644 index 0000000..6a090eb --- /dev/null +++ b/elections/migrations/0021_election_vote_restrictions.py @@ -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"), + ), + ] diff --git a/elections/models.py b/elections/models.py index a1704fc..3d07664 100644 --- a/elections/models.py +++ b/elections/models.py @@ -32,6 +32,8 @@ class Election(models.Model): start_date = models.DateTimeField(_("date et heure de début")) end_date = models.DateTimeField(_("date et heure de fin")) + vote_restrictions = models.TextField(_("conditions de vote"), blank=True) + restricted = models.BooleanField( _("restreint le vote à une liste de personnes"), default=True ) diff --git a/elections/templates/elections/election.html b/elections/templates/elections/election.html index e0cc7ed..b71a54b 100644 --- a/elections/templates/elections/election.html +++ b/elections/templates/elections/election.html @@ -86,6 +86,13 @@
+{# Précisions sur les modalités de vote #} +{% if election.vote_restrictions %} +
+
{{ election.vote_restrictions|linebreaksbr }}
+
+{% endif %} + {# Indications de connexion #} {% if election.start_date < current_time and election.end_date > current_time %} {% if can_vote %} diff --git a/elections/templates/elections/election_admin.html b/elections/templates/elections/election_admin.html index 78119fd..44c59be 100644 --- a/elections/templates/elections/election_admin.html +++ b/elections/templates/elections/election_admin.html @@ -123,6 +123,13 @@
{{ election.description|linebreaksbr }}
+{# Précisions sur les modalités de vote #} +{% if election.vote_restrictions %} +
+
{{ election.vote_restrictions|linebreaksbr }}
+
+{% endif %} + {# Liste des questions #} {% for q in election.questions.all %}
diff --git a/elections/templates/elections/election_voters.html b/elections/templates/elections/election_voters.html index 4507caa..ddf553d 100644 --- a/elections/templates/elections/election_voters.html +++ b/elections/templates/elections/election_voters.html @@ -29,6 +29,13 @@

+{# Précisions sur les modalités de vote #} +{% if election.vote_restrictions %} +
+
{{ election.vote_restrictions|linebreaksbr }}
+
+{% endif %} +
{% if election.restricted %}