-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #587 from MTES-MCT/feat-notrust-brevo
Ajout de validation des inputs utilisateurs de texte afin qu'ils ne contiennent que du texte
- Loading branch information
Showing
12 changed files
with
509 additions
and
211 deletions.
There are no files selected for viewing
133 changes: 133 additions & 0 deletions
133
project/migrations/0090_alter_historicalrequest_first_name_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Generated by Django 4.2.13 on 2024-09-30 09:42 | ||
|
||
from django.db import migrations, models | ||
import utils.validators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("project", "0089_rnupackagerequest"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="historicalrequest", | ||
name="first_name", | ||
field=models.CharField( | ||
max_length=150, null=True, validators=[utils.validators.is_alpha_validator], verbose_name="Prénom" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="historicalrequest", | ||
name="function", | ||
field=models.CharField( | ||
max_length=250, null=True, validators=[utils.validators.is_alpha_validator], verbose_name="Fonction" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="historicalrequest", | ||
name="last_name", | ||
field=models.CharField( | ||
max_length=150, null=True, validators=[utils.validators.is_alpha_validator], verbose_name="Nom" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="historicalrequest", | ||
name="organism", | ||
field=models.CharField( | ||
choices=[ | ||
("AGENCE", "Agence d'urbanisme"), | ||
("ASSOCI", "Association"), | ||
("BUREAU", "Bureau d'études"), | ||
("COMMUN", "Commune"), | ||
("DDT", "DDT"), | ||
("DDTM", "DDTM"), | ||
("DEAL", "DEAL"), | ||
("DREAL", "DREAL"), | ||
("DRIEAT", "DRIEAT"), | ||
("EPCI", "EPCI"), | ||
("PARTIC", "Particulier"), | ||
("SCOT", "SCOT"), | ||
("AUTRE", "Autre"), | ||
], | ||
default="COMMUN", | ||
max_length=30, | ||
validators=[utils.validators.is_alpha_validator], | ||
verbose_name="Organisme", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="historicalrequest", | ||
name="requested_document", | ||
field=models.CharField( | ||
choices=[ | ||
("rapport-conso", "Rapport de consommation"), | ||
("rapport-complet", "Rapport complet"), | ||
("rapport-local", "Rapport local"), | ||
], | ||
max_length=30, | ||
validators=[utils.validators.is_alpha_validator], | ||
verbose_name="Document demandé", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="request", | ||
name="first_name", | ||
field=models.CharField( | ||
max_length=150, null=True, validators=[utils.validators.is_alpha_validator], verbose_name="Prénom" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="request", | ||
name="function", | ||
field=models.CharField( | ||
max_length=250, null=True, validators=[utils.validators.is_alpha_validator], verbose_name="Fonction" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="request", | ||
name="last_name", | ||
field=models.CharField( | ||
max_length=150, null=True, validators=[utils.validators.is_alpha_validator], verbose_name="Nom" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="request", | ||
name="organism", | ||
field=models.CharField( | ||
choices=[ | ||
("AGENCE", "Agence d'urbanisme"), | ||
("ASSOCI", "Association"), | ||
("BUREAU", "Bureau d'études"), | ||
("COMMUN", "Commune"), | ||
("DDT", "DDT"), | ||
("DDTM", "DDTM"), | ||
("DEAL", "DEAL"), | ||
("DREAL", "DREAL"), | ||
("DRIEAT", "DRIEAT"), | ||
("EPCI", "EPCI"), | ||
("PARTIC", "Particulier"), | ||
("SCOT", "SCOT"), | ||
("AUTRE", "Autre"), | ||
], | ||
default="COMMUN", | ||
max_length=30, | ||
validators=[utils.validators.is_alpha_validator], | ||
verbose_name="Organisme", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="request", | ||
name="requested_document", | ||
field=models.CharField( | ||
choices=[ | ||
("rapport-conso", "Rapport de consommation"), | ||
("rapport-complet", "Rapport complet"), | ||
("rapport-local", "Rapport local"), | ||
], | ||
max_length=30, | ||
validators=[utils.validators.is_alpha_validator], | ||
verbose_name="Document demandé", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 4.2.13 on 2024-09-30 09:52 | ||
|
||
from django.db import migrations | ||
|
||
from utils.validators import is_alpha_valid | ||
|
||
|
||
def remove_invalid_user_inputs(apps, schema_editor): | ||
Request = apps.get_model("project", "Request") | ||
|
||
for request in Request.objects.all(): | ||
if not is_alpha_valid(request.first_name): | ||
request.first_name = "empty" | ||
if not is_alpha_valid(request.last_name): | ||
request.last_name = "empty" | ||
if not is_alpha_valid(request.function): | ||
request.function = "empty" | ||
if not is_alpha_valid(request.organism): | ||
request.organism = "COMMUN" | ||
if not is_alpha_valid(request.requested_document): | ||
request.requested_document = "rapport-complet" | ||
request.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("project", "0090_alter_historicalrequest_first_name_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(remove_invalid_user_inputs), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
users/migrations/0014_alter_user_first_name_alter_user_function_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Generated by Django 4.2.13 on 2024-09-30 09:17 | ||
|
||
from django.db import migrations, models | ||
import utils.validators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0013_auto_20240718_1408"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="user", | ||
name="first_name", | ||
field=models.CharField( | ||
max_length=150, validators=[utils.validators.is_alpha_validator], verbose_name="Prénom" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="user", | ||
name="function", | ||
field=models.CharField( | ||
max_length=250, validators=[utils.validators.is_alpha_validator], verbose_name="Fonction" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="user", | ||
name="last_name", | ||
field=models.CharField( | ||
max_length=150, validators=[utils.validators.is_alpha_validator], verbose_name="Nom" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="user", | ||
name="organism", | ||
field=models.CharField( | ||
choices=[ | ||
("AGENCE", "Agence d'urbanisme"), | ||
("ASSOCI", "Association"), | ||
("BUREAU", "Bureau d'études"), | ||
("COMMUN", "Commune"), | ||
("DDT", "DDT"), | ||
("DDTM", "DDTM"), | ||
("DEAL", "DEAL"), | ||
("DREAL", "DREAL"), | ||
("DRIEAT", "DRIEAT"), | ||
("EPCI", "EPCI"), | ||
("PARTIC", "Particulier"), | ||
("SCOT", "SCOT"), | ||
("AUTRE", "Autre"), | ||
], | ||
default="COMMUN", | ||
max_length=250, | ||
validators=[utils.validators.is_alpha_validator], | ||
verbose_name="Organisme", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 4.2.13 on 2024-09-30 09:48 | ||
|
||
from django.db import migrations | ||
from utils.validators import is_alpha_valid | ||
|
||
|
||
def remove_invalid_user_inputs(apps, schema_editor): | ||
User = apps.get_model("users", "User") | ||
|
||
for user in User.objects.all(): | ||
if not is_alpha_valid(user.first_name): | ||
user.first_name = "empty" | ||
if not is_alpha_valid(user.last_name): | ||
user.last_name = "empty" | ||
if not is_alpha_valid(user.function): | ||
user.function = "empty" | ||
if not is_alpha_valid(user.organism): | ||
user.organism = "COMMUN" | ||
user.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0014_alter_user_first_name_alter_user_function_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(remove_invalid_user_inputs), | ||
] |
Oops, something went wrong.