Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

FFT-104 Validation for Add Vacancy form #544

Merged
merged 4 commits into from
Nov 18, 2024
Merged
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
59 changes: 59 additions & 0 deletions payroll/migrations/0010_alter_vacancy_appointee_name_and_more.py
Original file line number Diff line number Diff line change
@@ -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 '-]*$",
)
],
),
),
]
59 changes: 59 additions & 0 deletions payroll/migrations/0011_alter_vacancy_appointee_name_and_more.py
Original file line number Diff line number Diff line change
@@ -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 '-]*$",
)
],
),
),
]
37 changes: 34 additions & 3 deletions payroll/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.core.validators import RegexValidator
from django.db import models


Expand Down Expand Up @@ -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.",
)
],
)
18 changes: 10 additions & 8 deletions payroll/templates/payroll/page/add_vacancy.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
{% block content %}
<h1 class="govuk-heading-l">Create Vacancy</h1>

<form method="post">
{% include "payroll/partials/_error_summary.html" with form=form %}

<form method="post" novalidate>
{% csrf_token %}
<div class="govuk-form-group">
{% include "_form_field.html" with field=form.recruitment_type %}
{% include "_form_field.html" with field=form.grade %}
{% include "_form_field.html" with field=form.recruitment_stage %}
{% include "_form_field.html" with field=form.programme_code %}
{% include "_form_field.html" with field=form.appointee_name %}
{% include "_form_field.html" with field=form.hiring_manager %}
{% include "_form_field.html" with field=form.hr_ref %}
{% include "payroll/partials/_form_field.html" with field=form.recruitment_type %}
{% include "payroll/partials/_form_field.html" with field=form.grade %}
{% include "payroll/partials/_form_field.html" with field=form.recruitment_stage %}
{% include "payroll/partials/_form_field.html" with field=form.programme_code %}
{% include "payroll/partials/_form_field.html" with field=form.appointee_name %}
{% include "payroll/partials/_form_field.html" with field=form.hiring_manager %}
{% include "payroll/partials/_form_field.html" with field=form.hr_ref %}
</div>
<button class="govuk-button" type="submit">Create Vacancy</button>
<a class="govuk-link" href="{% url 'payroll:edit' cost_centre_code financial_year %}">Back</a>
Expand Down
26 changes: 26 additions & 0 deletions payroll/templates/payroll/partials/_error_summary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% if form.errors %}
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
<h2 class="govuk-error-summary__title" id="error-summary-title">
There is a problem
</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
{% for field in form %}
{% if field.errors %}
{% for error in field.errors %}
<li>
<a href="#{{ field.id_for_label }}">{{ field.label }} - {{ error }}</a>
</li>
{% endfor %}
{% endif %}
{% endfor %}

{% for error in form.non_field_errors %}
<li>
<a href="#">{{ error }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}