Skip to content

Commit

Permalink
Merge branch 'inveniosoftware:master' into recordlandingpage_funding-…
Browse files Browse the repository at this point in the history
…display
  • Loading branch information
karkraeg authored Jan 6, 2025
2 parents 32bc035 + af193c7 commit 837d1c0
Show file tree
Hide file tree
Showing 26 changed files with 277 additions and 141 deletions.
11 changes: 0 additions & 11 deletions AUTHORS.rst

This file was deleted.

24 changes: 24 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@
Changes
=======

Version v13.0.0b1.dev24 (released 2024-12-10)

- fix: meta: add missing HighWire authors
- config: add subcommunity comment notifications

Version v13.0.0b1.dev23 (released 2024-11-28)

- assets: use the new copy feature to copy needed TinyMCE static assets

Version v13.0.0b1.dev22 (released 2024-11-28)

- installation: bump invenio-access
* This removes the invenio-admin dependency.

Version v13.0.0b1.dev21 (released 2024-11-28)

- installation: remove "sentry_sdk" extra from invenio-logging

Version v13.0.0b1.dev20 (released 2024-11-28)

- config: add subcommunity invitation request notifications
- requests: add subcommunity invitation request details page
- creatibutors: added config for identifiers scheme

Version v13.0.0b1.dev15 (released 2024-10-18)

- communities-ui: verified icon display logic change and deterministic sorting
Expand Down
9 changes: 0 additions & 9 deletions docs/authors.rst

This file was deleted.

2 changes: 1 addition & 1 deletion invenio_app_rdm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#
# See PEP 0440 for details - https://www.python.org/dev/peps/pep-0440

__version__ = "13.0.0b1.dev18"
__version__ = "13.0.0b1.dev25"

__all__ = ("__version__",)
53 changes: 12 additions & 41 deletions invenio_app_rdm/communities_ui/views/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@
UICommunityJSONSerializer,
)
from invenio_communities.errors import CommunityDeletedError
from invenio_communities.views.ui import (
not_found_error,
record_permission_denied_error,
record_tombstone_error,
)
from invenio_i18n import lazy_gettext as _
from invenio_pidstore.errors import PIDDeletedError, PIDDoesNotExistError
from invenio_rdm_records.collections import search_app_context as c_search_app_context
from invenio_records_resources.services.errors import PermissionDeniedError
from invenio_records_resources.services.errors import (
PermissionDeniedError,
RecordPermissionDeniedError,
)

from ..searchapp import search_app_context
from .communities import (
Expand All @@ -30,46 +38,6 @@
)


#
# Error handlers
#
def not_found_error(error):
"""Handler for 'Not Found' errors."""
return render_template(current_app.config["THEME_404_TEMPLATE"]), 404


def record_tombstone_error(error):
"""Tombstone page."""
# the RecordDeletedError will have the following properties,
# while the PIDDeletedError won't
record = getattr(error, "record", None)
if (record_ui := getattr(error, "result_item", None)) is not None:
if record is None:
record = record_ui._record
record_ui = UICommunityJSONSerializer().dump_obj(record_ui.to_dict())

# render a 404 page if the tombstone isn't visible
if not record.tombstone.is_visible:
return not_found_error(error)

# we only render a tombstone page if there is a record with a visible tombstone
return (
render_template(
"invenio_communities/tombstone.html",
record=record_ui,
),
410,
)


def record_permission_denied_error(error):
"""Handle permission denier error on record views."""
if not current_user.is_authenticated:
# trigger the flask-login unauthorized handler
return current_app.login_manager.unauthorized()
return render_template(current_app.config["THEME_403_TEMPLATE"]), 403


def _show_browse_page():
"""Whether the browse page should be visible in the menu."""
return (
Expand Down Expand Up @@ -118,6 +86,9 @@ def create_ui_blueprint(app):
blueprint.register_error_handler(
PermissionDeniedError, record_permission_denied_error
)
blueprint.register_error_handler(
RecordPermissionDeniedError, record_permission_denied_error
)
blueprint.register_error_handler(PIDDeletedError, record_tombstone_error)
blueprint.register_error_handler(CommunityDeletedError, record_tombstone_error)
blueprint.register_error_handler(PIDDoesNotExistError, not_found_error)
Expand Down
35 changes: 26 additions & 9 deletions invenio_app_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,6 @@ def files_rest_permission_factory(obj, action):
SEARCH_HOSTS = [{"host": "localhost", "port": 9200}]
"""Search hosts."""

# Invenio-Indexer
# ===============
# See https://invenio-indexer.readthedocs.io/en/latest/configuration.html

# We want that indexers are always explicit about the index they are indexing to.
# NOTE: Can be removed when https://github.com/inveniosoftware/invenio-indexer/pull/158 is merged and released.
INDEXER_DEFAULT_INDEX = None
"""Default index to use if no schema is defined."""

# Invenio-Base
# ============
# See https://invenio-base.readthedocs.io/en/latest/api.html#invenio_base.wsgi.wsgi_proxyfix # noqa
Expand Down Expand Up @@ -1003,6 +994,25 @@ def github_link_render(record):
APP_RDM_ADMIN_EMAIL_RECIPIENT = "[email protected]"
"""Admin e-mail"""

APP_RDM_IDENTIFIER_SCHEMES_UI = {
"orcid": {
"url_prefix": "http://orcid.org/",
"icon": "images/orcid.svg",
"label": "ORCID",
},
"ror": {
"url_prefix": "https://ror.org/",
"icon": "images/ror-icon.svg",
"label": "ROR",
},
"gnd": {
"url_prefix": "http://d-nb.info/gnd/",
"icon": "images/gnd-icon.svg",
"label": "GND",
},
}
"""Identifier Schemes UI config"""

# Invenio-Communities
# ===================

Expand Down Expand Up @@ -1358,6 +1368,8 @@ def github_link_render(record):
GrantUserAccessNotificationBuilder.type: GrantUserAccessNotificationBuilder,
# Comment request event
CommentRequestEventCreateNotificationBuilder.type: CommentRequestEventCreateNotificationBuilder,
community_notifications.SubComReqCommentNotificationBuilder.type: community_notifications.SubComReqCommentNotificationBuilder,
community_notifications.SubComInvCommentNotificationBuilder.type: community_notifications.SubComInvCommentNotificationBuilder,
# Community inclusion
CommunityInclusionAcceptNotificationBuilder.type: CommunityInclusionAcceptNotificationBuilder,
CommunityInclusionCancelNotificationBuilder.type: CommunityInclusionCancelNotificationBuilder,
Expand All @@ -1374,6 +1386,11 @@ def github_link_render(record):
community_notifications.SubCommunityCreate.type: community_notifications.SubCommunityCreate,
community_notifications.SubCommunityAccept.type: community_notifications.SubCommunityAccept,
community_notifications.SubCommunityDecline.type: community_notifications.SubCommunityDecline,
# Subcommunity invitation request
community_notifications.SubComInvitationCreate.type: community_notifications.SubComInvitationCreate,
community_notifications.SubComInvitationAccept.type: community_notifications.SubComInvitationAccept,
community_notifications.SubComInvitationDecline.type: community_notifications.SubComInvitationDecline,
community_notifications.SubComInvitationExpire.type: community_notifications.SubComInvitationExpire,
}
"""Notification builders."""

Expand Down
13 changes: 13 additions & 0 deletions invenio_app_rdm/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def finalize_app(app):

def init_config(app):
"""Initialize configuration."""
record_doi_required = (
app.config["RDM_PERSISTENT_IDENTIFIERS"].get("doi", {}).get("required")
)
parent_doi_required = (
app.config["RDM_PARENT_PERSISTENT_IDENTIFIERS"].get("doi", {}).get("required")
)

if record_doi_required != parent_doi_required:
raise Exception(
"Config variables RDM_PERSISTENT_IDENTIFIERS.doi.required and "
"RDM_PARENT_PERSISTENT_IDENTIFIERS.doi.required must be set to the same value."
)

if "COMMUNITIES_GROUPS_ENABLED" in app.config:
warnings.warn(
"COMMUNITIES_GROUPS_ENABLED config variable is deprecated. Please use USERS_RESOURCES_GROUPS_ENABLED "
Expand Down
21 changes: 13 additions & 8 deletions invenio_app_rdm/fixtures/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from invenio_access.permissions import system_identity
from invenio_db import db
from invenio_pages.proxies import current_pages_service
from invenio_pages.records.errors import PageNotFoundError
from invenio_rdm_records.fixtures.fixture import FixtureMixin


Expand Down Expand Up @@ -45,11 +46,15 @@ def page_data(self, page):

def create(self, entry):
"""Load a single page."""
data = {
"url": entry.pop("url"),
"title": entry.get("title"),
"content": self.page_data(entry.get("template")),
"description": entry.get("description"),
"template_name": current_app.config["PAGES_DEFAULT_TEMPLATE"],
}
current_pages_service.create(system_identity, data)
url = entry["url"]
try:
current_pages_service.read_by_url(system_identity, url)
except PageNotFoundError:
data = {
"url": url,
"title": entry.get("title", ""),
"content": self.page_data(entry["template"]),
"description": entry.get("description", ""),
"template_name": current_app.config["PAGES_DEFAULT_TEMPLATE"],
}
current_pages_service.create(system_identity, data)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h2 id="description-heading" class="sr-only">{{ _('Description') }}</h2>
{# description data is being sanitized by marshmallow in the backend #}
<div style="word-wrap: break-word;">
<p>{{ description | safe }}</p>
{{ description | safe }}
</div>
</section>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{#
Copyright (C) 2020 CERN.
Copyright (C) 2020-2024 CERN.
Copyright (C) 2020 Northwestern University.
Copyright (C) 2021 New York University.
Copyright (C) 2023 Front Matter.
Expand All @@ -12,7 +12,7 @@

{%- set meta_title = record.metadata.title|striptags -%}
{%- set meta_description = record.metadata.description|striptags -%}
{%- set meta_authors = record.creators|map(attribute='name') -%}
{%- set meta_authors = record.metadata.creators|map(attribute='person_or_org')|map(attribute='name') -%}
{%- set files = record.files %}

{{- meta_highwire(meta_title,meta_description,authors=meta_authors,publisher=meta_publisher,publication_date=record.publication_date|from_isodate,doi=record.pids.get("doi", {}).get("identifier"),keywords=record.metadata.subjects | map(attribute="subject"),url=record.links.self_html) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,33 @@
{% macro creatibutor_icon(creatibutor) %}
{% set identifier_found = namespace(value=False) %}

{% for scheme, identifier in creatibutor.person_or_org.identifiers|groupby("scheme") %}
{%- if scheme == "orcid" %}
{% set identifier_found.value = True %}
<a class="no-text-decoration" href="{{ identifier[0]['identifier']|pid_url('orcid') }}" aria-label="{{ creatibutor.person_or_org.name }}'s ORCID {{ _('profile') }}" title="{{ creatibutor.person_or_org.name }}'s ORCID {{ _('profile') }}">
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/orcid.svg') }}" alt="ORCID icon"/>
</a>
{%- elif scheme == "ror" %}
{% set identifier_found.value = True %}
<a href="{{ identifier[0]['identifier']|pid_url('ror') }}" aria-label="{{ creatibutor.person_or_org.name }}'s ROR {{ _('profile') }}" title="{{ creatibutor.person_or_org.name }}'s ROR {{ _('profile') }}">
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/ror-icon.svg') }}" alt="ROR icon"/>
</a>
{%- elif scheme == "gnd" %}
{% set identifier_found.value = True %}
<a href="{{ identifier[0]['identifier']|pid_url('gnd') }}" aria-label="{{ creatibutor.person_or_org.name }}'s GND {{ _('profile') }}" title="{{ creatibutor.person_or_org.name }}'s GND {{ _('profile') }}">
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/gnd-icon.svg') }}" alt="GND icon"/>
</a>
{%- endif %}
{% endfor %}
{% if config.APP_RDM_IDENTIFIER_SCHEMES_UI %}
{% for scheme, details in config.APP_RDM_IDENTIFIER_SCHEMES_UI.items() %}
{% for identifier in creatibutor.person_or_org.identifiers|selectattr("scheme", "equalto", scheme) %}
{% set identifier_found.value = True %}
<a href="{{ identifier.identifier|pid_url(scheme) }}"
aria-label="{{ creatibutor.person_or_org.name }}'s {{ details.label }} {{ _('profile') }}"
title="{{ creatibutor.person_or_org.name }}'s {{ details.label }} {{ _('profile') }}">
<img class="ml-5 inline-id-icon"
src="{{ url_for('static', filename=details.icon) }}"
alt="{{ details.label }} icon"/>
</a>
{% endfor %}
{% endfor %}
{% endif %}

{# if no identifiers: distinguish btw people and organizations #}
{%- if not identifier_found.value and creatibutor.person_or_org.type == 'organizational'%}
<i class="group icon"></i>
{%- endif %}
{# Fallback for missing identifiers #}
{% if not identifier_found.value %}
{% if creatibutor.person_or_org.type == 'organizational' %}
<i class="group icon"></i>
{% else %}
<i class="user icon"></i>
{% endif %}
{% endif %}
{% endmacro %}



{% macro show_creatibutors(creatibutors, show_affiliations=False, type="creators", show_role=False) %}
{% for creatibutor in creatibutors %}
<li class="creatibutor-wrap separated">
Expand Down Expand Up @@ -81,22 +82,32 @@

<section class="ui sixteen wide column content" id="{{ group }}-affiliations" aria-label="{{ _('Affiliations for') }} {{ group }}">
<ul>
{% for affiliation in affiliations %}
<li>
{{ affiliation[0] }}.

{% if affiliation[2] %}
{% for affiliation in affiliations %}
<li>
{{ affiliation[0] }}.

{% if affiliation[2] %}
{% set scheme, identifier = (affiliation[2].split(':', 1) if ':' in affiliation[2] else ('ror', affiliation[2])) %}
{% set scheme_config = config.APP_RDM_IDENTIFIER_SCHEMES_UI.get(scheme) %}

{% if scheme_config %}
<a class="no-text-decoration"
href="https://ror.org/{{affiliation[2]}}"
aria-label="{{ affiliation[1] }}'s ROR {{ _('profile') }}"
title="{{ affiliation[1] }}'s ROR {{ _('profile') }}"
href="{{ scheme_config.url_prefix + identifier }}"
aria-label="{{ affiliation[1] }}'s {{ scheme_config.label }} {{ _('profile') }}"
title="{{ affiliation[1] }}'s {{ scheme_config.label }} {{ _('profile') }}"
>
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/ror-icon.svg') }}" alt="ROR icon"/>
<img class="ml-5 inline-id-icon"
src="{{ url_for('static', filename=scheme_config.icon) }}"
alt="{{ scheme_config.label }} icon"
/>
</a>
{%- endif %}
{{affiliation[1]}}
</li>
{% endif %}
{% endif %}

{{ affiliation[1] }}
</li>
{% endfor %}

</ul>
</section>
{% endmacro %}
Loading

0 comments on commit 837d1c0

Please sign in to comment.