-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forms: added custom user profile form
- Loading branch information
1 parent
da1d885
commit e4c8825
Showing
3 changed files
with
47 additions
and
0 deletions.
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
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,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2023 CERN. | ||
# | ||
# Zenodo-RDM is free software; you can redistribute it and/or modify | ||
# it under the terms of the MIT License; see LICENSE file for more details. | ||
"""Forms module.""" | ||
|
||
from .profile_form import ZenodoProfileForm |
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,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2024 CERN. | ||
# | ||
# ZenodoRDM is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Form for user profiles.""" | ||
|
||
from invenio_i18n import lazy_gettext as _ | ||
from invenio_userprofiles.forms import ProfileForm, strip_filter | ||
from wtforms import StringField, validators | ||
from wtforms.validators import DataRequired, EqualTo, Length | ||
|
||
|
||
class ZenodoProfileForm(ProfileForm): | ||
"""Form for editing user profile with stricter validation.""" | ||
|
||
full_name = StringField( | ||
_("Full name"), | ||
validators=[ | ||
Length(max=255), | ||
DataRequired(message=_("Full name not provided.")), | ||
], | ||
filters=[strip_filter], | ||
) | ||
|
||
affiliations = StringField( | ||
_("Affiliations"), | ||
validators=[ | ||
Length(max=255), | ||
DataRequired(message=_("Affiliations not provided.")), | ||
], | ||
filters=[strip_filter], | ||
) |