This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Acantin/recruiter form accessibility fix #371
Open
AlexandreCantin
wants to merge
2
commits into
master
Choose a base branch
from
acantin/recruiter_form_accessibility_fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -210,6 +210,33 @@ def inject_user(): | |
def inject_jepostule_enabled(): | ||
return {'jepostule_enabled': jepostule_enabled} | ||
|
||
def inject_compute_input_attributes(): | ||
""" | ||
Template side function to populate 'aria-required' and | ||
'aria-describedby' attributes in form fields | ||
""" | ||
def compute_input_attributes(field): | ||
attrs = {} | ||
|
||
if field.flags.required: | ||
attrs['aria-required'] = 'true' | ||
|
||
# aria-describedby are used to link input fields to their description and/or error messages | ||
aria_describedby = [] | ||
if field.description: | ||
aria_describedby.append('{}_description'.format(field.id)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Juste pour la forme, en Python 3 il y a les f-strings qui te permettent d'écrire comme ça : aria_describedby.append(f"{field.id}_description") |
||
if field.errors: | ||
aria_describedby.append('{}_errors'.format(field.id)) | ||
|
||
if aria_describedby: | ||
attrs['aria-describedby'] = ' '.join(aria_describedby) | ||
|
||
return attrs | ||
|
||
return dict(compute_input_attributes=compute_input_attributes) | ||
|
||
|
||
flask_app.context_processor(inject_compute_input_attributes) | ||
flask_app.context_processor(inject_dict_for_all_templates) | ||
flask_app.context_processor(inject_user) | ||
flask_app.context_processor(inject_jepostule_enabled) | ||
|
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ class OfficeIdentificationForm(FlaskForm): | |
'N° de Siret *', | ||
validators=[ | ||
DataRequired(), | ||
Regexp('[0-9]{14}', message=("Le siret de l'établissement est invalide (14 chiffres)")) | ||
Regexp('[0-9]{14}', message=("Le siret de l'établissement est invalide (14 chiffres sans espace)")) | ||
], | ||
description="14 chiffres, sans espace. Exemple: 36252187900034", | ||
) | ||
|
@@ -34,30 +34,22 @@ class OfficeIdentificationForm(FlaskForm): | |
first_name = StringField('Prénom *', validators=[DataRequired()]) | ||
phone = TelField( | ||
'Téléphone *', | ||
validators=[DataRequired(), Regexp(PHONE_REGEX)], | ||
render_kw={"placeholder": "01 77 86 39 49, +331 77 86 39 49"} | ||
description="Exemple: 01 77 86 39 49 ou +331 77 86 39 49", | ||
validators=[DataRequired(), Regexp(PHONE_REGEX, message="Entrée invalide. Exemple valide: 01 77 86 39 49 ou +331 77 86 39 49")], | ||
) | ||
email = EmailField( | ||
'Adresse email *', | ||
validators=[DataRequired(), Email()], | ||
render_kw={"placeholder": "[email protected]"} | ||
description="Exemple: [email protected]", | ||
validators=[DataRequired(), Email(message="Entrée invalide. Exemple valide: [email protected]")], | ||
) | ||
|
||
|
||
class OfficeHiddenIdentificationForm(FlaskForm): | ||
siret = HiddenField('Siret *', validators=[DataRequired()]) | ||
last_name = HiddenField('Nom *', validators=[DataRequired()]) | ||
first_name = HiddenField('Prénom *', validators=[DataRequired()]) | ||
phone = HiddenField( | ||
'Téléphone *', | ||
validators=[DataRequired(), Regexp(PHONE_REGEX)], | ||
render_kw={"placeholder": "01 77 86 39 49, +331 77 86 39 49"} | ||
) | ||
email = HiddenField( | ||
'Adresse email *', | ||
validators=[DataRequired(), Email()], | ||
render_kw={"placeholder": "[email protected]"} | ||
) | ||
phone = HiddenField('Téléphone *', validators=[DataRequired(), Regexp(PHONE_REGEX)]) | ||
email = HiddenField('Adresse email *', validators=[DataRequired(), Email()]) | ||
|
||
|
||
class OfficeOtherRequestForm(OfficeHiddenIdentificationForm): | ||
|
@@ -77,27 +69,33 @@ class OfficeUpdateCoordinatesForm(OfficeHiddenIdentificationForm): | |
new_contact_mode = RadioField('Mode de contact à privilégier', choices=CONTACT_MODES, default='email') | ||
new_website = StringField( | ||
'Site Internet', | ||
validators=[URL(), Optional()], render_kw={"placeholder": "http://exemple.com"} | ||
description="Exemple: http://exemple.com", | ||
validators=[URL(message="Entrée invalide. Exemple: http://exemple.com"), Optional()] | ||
) | ||
new_email = EmailField( | ||
'Email recruteur', | ||
validators=[Email(), Optional()], render_kw={"placeholder": "[email protected]"} | ||
description="Exemple: [email protected]", | ||
validators=[Email(message="Entrée invalide. Exemple valide: [email protected]"), Optional()] | ||
) | ||
new_phone = StringField( | ||
'Téléphone', | ||
validators=[Optional(), Regexp(PHONE_REGEX)], | ||
render_kw={"placeholder": "01 77 86 39 49, +331 77 86 39 49"} | ||
description="Exemple: 01 77 86 39 49 ou +331 77 86 39 49", | ||
validators=[Optional(), Regexp(PHONE_REGEX, message="Entrée invalide. Exemple valide: 01 77 86 39 49 ou +331 77 86 39 49")] | ||
) | ||
social_network = StringField( | ||
'Réseau social', | ||
description="Exemple: https://twitter.com/0123456_abcdef", | ||
validators=[URL(message="Entrée invalide. Exemple: https://twitter.com/0123456_abcdef"), Optional()] | ||
) | ||
social_network = StringField('Réseau social', validators=[URL(), Optional()]) | ||
new_email_alternance = EmailField( | ||
'Email recruteur spécialisé alternance', | ||
validators=[validators.optional(), Email()], | ||
render_kw={"placeholder": "exemple-alternance@domaine.com"} | ||
description="Exemple: [email protected]", | ||
validators=[validators.optional(), Email(message="Entrée invalide. Exemple valide: [email protected]")] | ||
) | ||
new_phone_alternance = StringField( | ||
'Téléphone du recruteur spécialisé alternance', | ||
validators=[validators.optional(), Regexp(PHONE_REGEX)], | ||
render_kw={"placeholder": "01 77 86 39 49, +331 77 86 39 49"} | ||
description="Exemple: 01 77 86 39 49 ou +331 77 86 39 49", | ||
validators=[validators.optional(), Regexp(PHONE_REGEX, message="Entrée invalide. Exemple valide: 01 77 86 39 49 ou +331 77 86 39 49")] | ||
) | ||
rgpd_consent = BooleanField( | ||
'En cochant cette case, vous consentez à diffuser des données à caractère personnel sur les services numériques de Pôle emploi.', | ||
|
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 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 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 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 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 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 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 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça mérite une docstring qui explique ce que ça fait !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍