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

forms: added custom user profile form #1109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ from zenodo_rdm.files import storage_factory
from zenodo_rdm.github.schemas import CitationMetadataSchema
from zenodo_rdm.legacy.resources import record_serializers
from zenodo_rdm.metrics.config import METRICS_CACHE_UPDATE_INTERVAL
from zenodo_rdm.forms import ZenodoProfileForm
from zenodo_rdm.moderation.errors import UserBlockedException
from zenodo_rdm.moderation.handlers import CommunityModerationHandler, RecordModerationHandler
from zenodo_rdm.openaire.records.components import OpenAIREComponent
Expand Down Expand Up @@ -735,6 +736,8 @@ USERPROFILES_READ_ONLY = (
False # allow users to change profile info (name, email, etc...)
)

USERPROFILES_FORM_CLASS = ZenodoProfileForm

THEME_SHOW_FRONTPAGE_INTRO_SECTION = False
APP_RDM_RECORD_LANDING_PAGE_TEMPLATE = "zenodo_rdm/records/detail.html"

Expand Down
9 changes: 9 additions & 0 deletions site/zenodo_rdm/forms/__init__.py
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
35 changes: 35 additions & 0 deletions site/zenodo_rdm/forms/profile_form.py
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],
)