initial phone number validation

pull/1/head
parent 5b0ca61d17
commit 145f9c8187

@ -1,3 +1,4 @@
## The following requirements were added by pip freeze:
amqp==5.1.1 amqp==5.1.1
asgiref==3.5.0 asgiref==3.5.0
async-timeout==4.0.2 async-timeout==4.0.2
@ -11,11 +12,13 @@ click-plugins==1.1.1
click-repl==0.2.0 click-repl==0.2.0
Deprecated==1.2.13 Deprecated==1.2.13
Django==4.0.4 Django==4.0.4
django-phonenumber-field==6.1.0
icalendar==4.0.9 icalendar==4.0.9
idna==3.3 idna==3.3
kombu==5.2.4 kombu==5.2.4
librabbitmq==2.0.0 librabbitmq==2.0.0
packaging==21.3 packaging==21.3
phonenumbers==8.12.47
prompt-toolkit==3.0.29 prompt-toolkit==3.0.29
psycopg2-binary==2.9.3 psycopg2-binary==2.9.3
pyparsing==3.0.8 pyparsing==3.0.8

@ -1,6 +1,6 @@
from django import forms from django import forms
from .models import Helper from .models import Helper
from phonenumber_field.formfields import PhoneNumberField
def text_input(type=None): def text_input(type=None):
attrs = {"class": "input"} attrs = {"class": "input"}
@ -15,7 +15,7 @@ class RegisterForm(forms.Form):
max_length=Helper.name.field.max_length, label="Name", widget=text_input() max_length=Helper.name.field.max_length, label="Name", widget=text_input()
) )
# actually verify phone number, lol # actually verify phone number, lol
phone = forms.CharField( phone = PhoneNumberField(
max_length=Helper.phone.field.max_length, max_length=Helper.phone.field.max_length,
label="Handynummer für Benachrichtigungen", label="Handynummer für Benachrichtigungen",
help_text="Wir nutzen deine Handynummer, um dir Benachrichtigungen zu deinen Schichten zu schicken. Wir löschen alle Daten 7 Tage nach dem Festival.", help_text="Wir nutzen deine Handynummer, um dir Benachrichtigungen zu deinen Schichten zu schicken. Wir löschen alle Daten 7 Tage nach dem Festival.",

@ -0,0 +1,19 @@
# Generated by Django 4.0.4 on 2022-04-27 12:41
from django.db import migrations
import phonenumber_field.modelfields
class Migration(migrations.Migration):
dependencies = [
('app', '0006_shift_deleted'),
]
operations = [
migrations.AlterField(
model_name='helper',
name='phone',
field=phonenumber_field.modelfields.PhoneNumberField(editable=False, max_length=128, primary_key=True, region=None, serialize=False),
),
]

@ -4,7 +4,7 @@ from django.shortcuts import reverse
from datetime import timedelta from datetime import timedelta
from django.utils import timezone from django.utils import timezone
from django.db.models import F, Count, Q, ExpressionWrapper from django.db.models import F, Count, Q, ExpressionWrapper
from phonenumber_field.modelfields import PhoneNumberField
class Room(models.Model): class Room(models.Model):
name = models.CharField(max_length=200, primary_key=True) name = models.CharField(max_length=200, primary_key=True)
@ -32,8 +32,7 @@ class Shift(models.Model):
class Helper(models.Model): class Helper(models.Model):
# todo: add propper phone number validation, maybe even country code? phone = PhoneNumberField(primary_key=True, editable=False)
phone = models.CharField(max_length=200, primary_key=True, editable=False)
name = models.CharField(max_length=200) name = models.CharField(max_length=200)
# change this to a generic state variable to allow for number blocking/account deactivation? # change this to a generic state variable to allow for number blocking/account deactivation?
number_validated = models.BooleanField(default=False) number_validated = models.BooleanField(default=False)

@ -16,6 +16,9 @@
{{ field }} {{ field }}
</div> </div>
{% endif %} {% endif %}
{%for error in field.errors %}
<p class="is-danger help"> {{ error }} </div>
{% endfor %}
{% if field.help_text %} {% if field.help_text %}
<p class="is-size-7 mt-1">{{ field.help_text }}</p> <p class="is-size-7 mt-1">{{ field.help_text }}</p>
{% endif %} {% endif %}

@ -46,6 +46,7 @@ INSTALLED_APPS = [
"django.contrib.sessions", "django.contrib.sessions",
"django.contrib.messages", "django.contrib.messages",
"django.contrib.staticfiles", "django.contrib.staticfiles",
"phonenumber_field",
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -162,3 +163,5 @@ if getenv("SENTRY_DSN"):
auto_session_tracking=False, auto_session_tracking=False,
traces_sample_rate=0, traces_sample_rate=0,
) )
PHONENUMBER_DEFAULT_REGION = "DE"
Loading…
Cancel
Save