diff --git a/payroll/migrations/0010_alter_vacancy_appointee_name_and_more.py b/payroll/migrations/0010_alter_vacancy_appointee_name_and_more.py new file mode 100644 index 000000000..23dd74bae --- /dev/null +++ b/payroll/migrations/0010_alter_vacancy_appointee_name_and_more.py @@ -0,0 +1,59 @@ +# Generated by Django 4.2.16 on 2024-11-18 12:07 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("payroll", "0009_remove_vacancy_programme_switch_vacancy"), + ] + + operations = [ + migrations.AlterField( + model_name="vacancy", + name="appointee_name", + field=models.CharField( + blank=True, + max_length=255, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Only letters, spaces, - and ' are allowed", + regex="^[a-zA-Z '-]*$", + ) + ], + ), + ), + migrations.AlterField( + model_name="vacancy", + name="hiring_manager", + field=models.CharField( + blank=True, + max_length=255, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Only letters, spaces, - and ' are allowed", + regex="^[a-zA-Z '-]*$", + ) + ], + ), + ), + migrations.AlterField( + model_name="vacancy", + name="hr_ref", + field=models.CharField( + blank=True, + max_length=255, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Only letters, spaces, - and ' are allowed", + regex="^[a-zA-Z '-]*$", + ) + ], + ), + ), + ] diff --git a/payroll/migrations/0011_alter_vacancy_appointee_name_and_more.py b/payroll/migrations/0011_alter_vacancy_appointee_name_and_more.py new file mode 100644 index 000000000..61a1897a4 --- /dev/null +++ b/payroll/migrations/0011_alter_vacancy_appointee_name_and_more.py @@ -0,0 +1,59 @@ +# Generated by Django 4.2.16 on 2024-11-18 13:52 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("payroll", "0010_alter_vacancy_appointee_name_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="vacancy", + name="appointee_name", + field=models.CharField( + blank=True, + max_length=255, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Only letters, spaces, - and ' are allowed.", + regex="^[a-zA-Z '-]*$", + ) + ], + ), + ), + migrations.AlterField( + model_name="vacancy", + name="hiring_manager", + field=models.CharField( + blank=True, + max_length=255, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Only letters, spaces, - and ' are allowed.", + regex="^[a-zA-Z '-]*$", + ) + ], + ), + ), + migrations.AlterField( + model_name="vacancy", + name="hr_ref", + field=models.CharField( + blank=True, + max_length=255, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Only letters, spaces, - and ' are allowed.", + regex="^[a-zA-Z '-]*$", + ) + ], + ), + ), + ] diff --git a/payroll/models.py b/payroll/models.py index 9ce1e5e95..807c36d60 100644 --- a/payroll/models.py +++ b/payroll/models.py @@ -1,3 +1,4 @@ +from django.core.validators import RegexValidator from django.db import models @@ -154,6 +155,36 @@ class Meta: choices=RecruitmentStage.choices, default=RecruitmentStage.PREPARING ) - appointee_name = models.CharField(max_length=255, null=True, blank=True) - hiring_manager = models.CharField(max_length=255, null=True, blank=True) - hr_ref = models.CharField(max_length=255, null=True, blank=True) + appointee_name = models.CharField( + max_length=255, + null=True, + blank=True, + validators=[ + RegexValidator( + regex=r"^[a-zA-Z '-]*$", + message="Only letters, spaces, - and ' are allowed.", + ) + ], + ) + hiring_manager = models.CharField( + max_length=255, + null=True, + blank=True, + validators=[ + RegexValidator( + regex=r"^[a-zA-Z '-]*$", + message="Only letters, spaces, - and ' are allowed.", + ) + ], + ) + hr_ref = models.CharField( + max_length=255, + null=True, + blank=True, + validators=[ + RegexValidator( + regex=r"^[a-zA-Z '-]*$", + message="Only letters, spaces, - and ' are allowed.", + ) + ], + ) diff --git a/payroll/templates/payroll/page/add_vacancy.html b/payroll/templates/payroll/page/add_vacancy.html index 7df2ae8fe..e824fa8e0 100644 --- a/payroll/templates/payroll/page/add_vacancy.html +++ b/payroll/templates/payroll/page/add_vacancy.html @@ -13,16 +13,18 @@ {% block content %}