Skip to content

Commit

Permalink
forms: added custom user profile form
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 committed Dec 18, 2024
1 parent da1d885 commit 6f3ea8b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
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=_("Affiliation not provided.")),
],
filters=[strip_filter],
)

0 comments on commit 6f3ea8b

Please sign in to comment.