Skip to content

Commit e4c8825

Browse files
committed
forms: added custom user profile form
1 parent da1d885 commit e4c8825

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

invenio.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ from zenodo_rdm.files import storage_factory
7373
from zenodo_rdm.github.schemas import CitationMetadataSchema
7474
from zenodo_rdm.legacy.resources import record_serializers
7575
from zenodo_rdm.metrics.config import METRICS_CACHE_UPDATE_INTERVAL
76+
from zenodo_rdm.forms import ZenodoProfileForm
7677
from zenodo_rdm.moderation.errors import UserBlockedException
7778
from zenodo_rdm.moderation.handlers import CommunityModerationHandler, RecordModerationHandler
7879
from zenodo_rdm.openaire.records.components import OpenAIREComponent
@@ -735,6 +736,8 @@ USERPROFILES_READ_ONLY = (
735736
False # allow users to change profile info (name, email, etc...)
736737
)
737738

739+
USERPROFILES_FORM_CLASS = ZenodoProfileForm
740+
738741
THEME_SHOW_FRONTPAGE_INTRO_SECTION = False
739742
APP_RDM_RECORD_LANDING_PAGE_TEMPLATE = "zenodo_rdm/records/detail.html"
740743

site/zenodo_rdm/forms/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2023 CERN.
4+
#
5+
# Zenodo-RDM is free software; you can redistribute it and/or modify
6+
# it under the terms of the MIT License; see LICENSE file for more details.
7+
"""Forms module."""
8+
9+
from .profile_form import ZenodoProfileForm
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2024 CERN.
4+
#
5+
# ZenodoRDM is free software; you can redistribute it and/or modify it
6+
# under the terms of the MIT License; see LICENSE file for more details.
7+
8+
"""Form for user profiles."""
9+
10+
from invenio_i18n import lazy_gettext as _
11+
from invenio_userprofiles.forms import ProfileForm, strip_filter
12+
from wtforms import StringField, validators
13+
from wtforms.validators import DataRequired, EqualTo, Length
14+
15+
16+
class ZenodoProfileForm(ProfileForm):
17+
"""Form for editing user profile with stricter validation."""
18+
19+
full_name = StringField(
20+
_("Full name"),
21+
validators=[
22+
Length(max=255),
23+
DataRequired(message=_("Full name not provided.")),
24+
],
25+
filters=[strip_filter],
26+
)
27+
28+
affiliations = StringField(
29+
_("Affiliations"),
30+
validators=[
31+
Length(max=255),
32+
DataRequired(message=_("Affiliations not provided.")),
33+
],
34+
filters=[strip_filter],
35+
)

0 commit comments

Comments
 (0)