Skip to content

Issue 333 : Adding new optional field "Zip code" to petition signature #334

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pytition/locale/fr_FR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Pytition\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-15 21:12+0200\n"
"PO-Revision-Date: 2024-03-31 22:24+0200\n"
"PO-Revision-Date: 2025-03-15 18:44+0200\n"
"Last-Translator: Fares Sellaouti <fares@rhone.pcf.fr>\n"
"Language-Team: French (France) <https://weblate.framasoft.org/projects/"
"pytition/pytitions/fr_FR/>\n"
Expand Down Expand Up @@ -469,6 +469,10 @@ msgstr "Nom *"
msgid "Phone number"
msgstr "Numéro de téléphone"

#: pytition/petition/forms.py:35 pytition/petition/models.py:456
msgid "Zip code"
msgstr "Code postal"

#: pytition/petition/forms.py:27
msgid "Email address *"
msgstr "Adresse email *"
Expand Down
7 changes: 5 additions & 2 deletions pytition/petition/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@ class SignatureForm(ModelForm):
required=False)
class Meta:
model = Signature
fields = ['first_name', 'last_name', 'phone', 'email', 'subscribed_to_mailinglist']
fields = ['first_name', 'last_name', 'phone', 'zip_code', 'email', 'subscribed_to_mailinglist']
widgets = {
'first_name': forms.TextInput(attrs={'placeholder': _('First name *'), 'class': 'form-control has-feedback eaFullWidthContent',
'group_class': 'form-group has-feedback'}),
'last_name': forms.TextInput(attrs={'placeholder': _('Last name *'), 'class': 'form-control has-feedback eaFullWidthContent',
'group_class': 'form-group has-feedback'}),
'phone': forms.TextInput(attrs={'placeholder': _('Phone number'), 'class': 'form-control has-feedback eaFullWidthContent',
'group_class': 'form-group has-feedback'}),
'zip_code': forms.TextInput(
attrs={'placeholder': _('Zip code'), 'class': 'form-control has-feedback eaFullWidthContent',
'group_class': 'form-group has-feedback'}),
'email': forms.EmailInput(attrs={'placeholder': _('Email address *'), 'class': 'form-control has-feedback eaFullWidthContent',
'group_class': 'form-group has-feedback'}),
}

labels = { f : '' for f in ['first_name', 'last_name', 'phone', 'email'] }
labels = {f: '' for f in ['first_name', 'last_name', 'phone', 'zip_code', 'email']}

def __init__(self, petition=None, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
18 changes: 18 additions & 0 deletions pytition/petition/migrations/0026_add_signature_zip_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-09 06:02

import colorfield.fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('petition', '0025_remove_petitiontemplate_has_share_buttons'),
]

operations = [
migrations.AddField(
model_name='signature',
name='zip_code',
field=models.CharField(max_length=5)
),
]
28 changes: 14 additions & 14 deletions pytition/petition/models.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
from django.db import models
from django.utils.html import mark_safe, strip_tags
from django.utils.text import slugify
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from django.core.exceptions import ValidationError
from django.db.models.signals import post_save, post_delete, pre_save
from django.dispatch import receiver
import html
import uuid

from colorfield.fields import ColorField
from django.conf import settings
from django.contrib.auth.hashers import get_hasher
from django.core.exceptions import ValidationError
from django.db import models
from django.db import transaction
from django.db.models.signals import post_save, post_delete, pre_save
from django.dispatch import receiver
from django.urls import reverse
from django.utils import timezone

from tinymce import models as tinymce_models
from colorfield.fields import ColorField
from django.utils.html import mark_safe, strip_tags
from django.utils.text import slugify
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from phonenumber_field.modelfields import PhoneNumberField
from tinymce import models as tinymce_models

from .helpers import sanitize_html

import html
import uuid


# ----------------------------------- PytitionUser ----------------------------
class PytitionUser(models.Model):
Expand Down Expand Up @@ -454,6 +453,7 @@ class Signature(models.Model):
last_name = models.CharField(max_length=50, verbose_name=gettext_lazy("Last name"))
phone = PhoneNumberField(max_length=20, blank=True, verbose_name=gettext_lazy("Phone number"))
email = models.EmailField(verbose_name=gettext_lazy("Email address"))
zip_code = models.CharField(max_length=5, verbose_name=gettext_lazy("Zip code"))
confirmation_hash = models.CharField(max_length=128)
confirmed = models.BooleanField(default=False, verbose_name=gettext_lazy("Confirmed"))
petition = models.ForeignKey(Petition, on_delete=models.CASCADE, verbose_name=gettext_lazy("Petition"))
Expand Down