Skip to content

Commit b47f3a3

Browse files
committed
First version of the release process, with the pages for the list of releases and dealing with records. It includes user login, communities and a bunch of new dependencies.
Co-authored-by: Diana Rand <54885108+dianarand@users.noreply.github.com>
1 parent c5d31df commit b47f3a3

47 files changed

Lines changed: 4050 additions & 50 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cernopendata/config.py

Lines changed: 100 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929

3030
from celery.schedules import crontab, timedelta
3131
from flask import request
32+
from invenio_accounts.views import rest as accounts_rest
33+
from invenio_cern_sync.sso import cern_keycloak, cern_remote_app_name, handlers
34+
from invenio_cern_sync.sso.api import confirm_registration_form
35+
from invenio_cern_sync.users.profile import CERNUserProfileSchema
36+
from invenio_oauthclient.views.client import auto_redirect_login
3237
from invenio_records_files.api import _Record
3338
from invenio_records_rest.config import RECORDS_REST_ENDPOINTS
3439
from invenio_records_rest.facets import nested_filter, range_filter, terms_filter
@@ -43,8 +48,18 @@
4348
from urllib3.exceptions import InsecureRequestWarning
4449

4550
from cernopendata.cold_storage.tasks import CheckTransfersTask
46-
from cernopendata.modules.pages.config import *
51+
52+
# noinspection PyUnresolvedReferences
53+
# from cernopendata.modules.pages.config import *
54+
# noinspection PyUnresolvedReferences
55+
from cernopendata.modules.releases import models
56+
from cernopendata.modules.releases.utils import (
57+
user_info_with_cern_roles,
58+
user_payload_with_cern_roles,
59+
)
4760
from cernopendata.modules.search_ui.helpers import CODSearchAppInvenioRestConfigHelper
61+
62+
# noinspection PyUnresolvedReferences
4863
from cernopendata.modules.theme.config import *
4964
from cernopendata.tasks import ProcessEosDumpTask
5065

@@ -68,7 +83,23 @@
6883

6984
# Piwik tracking code: set None to disabled it
7085
THEME_PIWIK_ID = os.environ.get("PIWIK_ID", None)
71-
ACCOUNTS_SESSION_ACTIVITY_ENABLED = None
86+
# ACCOUNTS_SESSION_ACTIVITY_ENABLED = True
87+
# ACCOUNTS_REGISTER = True # allow registration
88+
# ACCOUNTS_CONFIRM_EMAIL = None# require email confirmation (recommended)
89+
# ACCOUNTS_SESSION_RESTORATION = True
90+
# ACCOUNTS_REST_AUTH_VIEWS= True
91+
# SECURITY_REGISTERABLE = True
92+
# SECURITY_RECOVERABLE = True
93+
# SECURITY_CHANGEABLE = True
94+
95+
# SECURITY_LOGIN_URL = "/login"
96+
# SECURITY_LOGOUT_URL = "/logout"
97+
# SECURITY_REGISTER_URL = "/signup"
98+
99+
# Required for sessions
100+
SECRET_KEY = "change-me-pleaaaseeeee!!!"
101+
# SECURITY_PASSWORD_SALT = "change-me-too"
102+
72103
SITE_URL = os.environ.get("CERNOPENDATA_SITE_URL", "opendata.cern.ch")
73104

74105
# Logging - Set up Sentry for Invenio-Logging
@@ -163,7 +194,6 @@
163194
"params": {"preprocessors": [flag_robots, anonymize_user, build_record_unique_id]},
164195
}
165196

166-
167197
STATS_AGGREGATIONS = {
168198
"file-download-agg": {
169199
"templates": "invenio_stats.contrib.aggregations.aggr_file_download",
@@ -253,7 +283,6 @@
253283
},
254284
}
255285

256-
257286
CELERY_BEAT_SCHEDULE = {
258287
# indexing of statistics events & aggregations
259288
"stats-process-events": {
@@ -276,11 +305,17 @@
276305
# JSONSchemas
277306
JSONSCHEMAS_ENDPOINT = "/schema"
278307
JSONSCHEMAS_HOST = "opendata.cern.ch"
279-
JSONSCHEMAS_URL_SCHEME = "http"
308+
# JSONSCHEMAS_URL_SCHEME = "http"
309+
JSONSCHEMAS_REPLACE_REFS = True
280310

281311
# HOST_URI
282-
HOST_URI = "{}://{}".format(JSONSCHEMAS_URL_SCHEME, JSONSCHEMAS_HOST)
283-
312+
# HOST_URI = "{}://{}".format(JSONSCHEMAS_URL_SCHEME, JSONSCHEMAS_HOST)
313+
#
314+
# TODO: This is a hack! There is an issue with the resolver. Setting these two things make the test fail
315+
# If we don't set them, the curation process can't validate the json schema
316+
if "CERNOPENDATA_CERN_APP_CREDENTIALS" in os.environ:
317+
RECORDS_REFRESOLVER_STORE = "invenio_jsonschemas.proxies.current_refresolver_store"
318+
RECORDS_REFRESOLVER_CLS = "invenio_records.resolver.InvenioRefResolver"
284319
# Records
285320
# Add tuple as array type on record validation
286321
# http://python-jsonschema.readthedocs.org/en/latest/validate/#validating-types
@@ -501,6 +536,15 @@ def _query_parser_and(qstr=None):
501536
),
502537
}
503538
}
539+
COVER_TEMPLATE = "invenio_theme/page_cover.html"
540+
ACCOUNTS_COVER_TEMPLATE = "invenio_accounts/base_cover.html"
541+
ACCOUNTS_BASE_TEMPLATE = "invenio_accounts/base.html"
542+
# After 'Create app'
543+
# MAIL_SERVER='smtp.example.com'
544+
# MAIL_PORT = 465
545+
# MAIL_USE_SSL= True
546+
# MAIL_USERNAME = 'username'
547+
COMMUNITIES_IDENTITIES_CACHE_REDIS_URL = "redis://cache:6379/0"
504548

505549
# TODO: based on invenio-records-rest default config
506550
RECORDS_REST_DEFAULT_SORT = dict(
@@ -634,7 +678,6 @@ def _query_parser_and(qstr=None):
634678
"invenio_records_rest": CODSearchAppInvenioRestConfigHelper,
635679
}
636680

637-
638681
SEARCH_UI_SEARCH_VIEW = search_legacy
639682
# OAI-PMH
640683
# =======
@@ -718,3 +761,52 @@ def _query_parser_and(qstr=None):
718761

719762
# THIS ONE IS ONLY FOR THE DEVELOPMENT
720763
RATELIMIT_PER_ENDPOINT = {"static": "600 per minute"}
764+
765+
# Checking communities
766+
THEME_FRONTPAGE = False
767+
# Enable communities
768+
COMMUNITIES_ENABLED = True
769+
770+
ACCOUNTS_LOCAL_LOGIN_ENABLED = False
771+
ACCOUNTS_LOGIN_VIEW_FUNCTION = auto_redirect_login
772+
773+
ACCOUNTS_USER_PROFILE_SCHEMA = CERNUserProfileSchema()
774+
775+
USERPROFILES_EXTEND_SECURITY_FORMS = True
776+
CERN_SYNC_KEYCLOAK_BASE_URL = "https://auth.cern.ch/"
777+
778+
OAUTHCLIENT_SIGNUP_FORM = confirm_registration_form
779+
OAUTHCLIENT_CERN_REALM_URL = "https://auth.cern.ch/auth/realms/cern"
780+
OAUTHCLIENT_CERN_USER_INFO_URL = (
781+
"https://auth.cern.ch/auth/realms/cern/protocol/openid-connect/userinfo"
782+
)
783+
OAUTHCLIENT_SETTINGS_TEMPLATE = "invenio_oauthclient/settings/base.html"
784+
OAUTHCLIENT_CERN_VERIFY_EXP = True
785+
OAUTHCLIENT_CERN_VERIFY_AUD = False
786+
OAUTHCLIENT_CERN_USER_INFO_FROM_ENDPOINT = True
787+
OAUTHCLIENT_CERN_OPENID_ALLOWED_ROLES = [
788+
"cms-curator",
789+
"atlas-curator",
790+
"delphi-curator",
791+
"alice-curator",
792+
"default-role",
793+
]
794+
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = True
795+
796+
OAUTH_REMOTE_APP_NAME = "cern_openid"
797+
OAUTHCLIENT_REMOTE_APPS = {
798+
cern_remote_app_name: cern_keycloak.remote_app,
799+
}
800+
CERN_APP_CREDENTIALS = {
801+
"consumer_key": "opendata-dev",
802+
"consumer_secret": os.environ.get(
803+
"CERNOPENDATA_CERN_APP_CREDENTIALS", "<CHANGEME>"
804+
),
805+
}
806+
807+
accounts_rest.default_user_payload = user_payload_with_cern_roles
808+
handlers["signup_handler"]["info"] = user_info_with_cern_roles
809+
810+
# OAUTHCLIENT_SETTINGS_TEMPLATE = 'invenio_theme/page_settings.html'
811+
COMMUNITIES_CUSTOM_FIELDS = None
812+
MAX_CONTENT_LENGTH = 1000 * 1024 * 1024

cernopendata/modules/fixtures/cli.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,6 @@ def _handle_record_files(record, data, logger=None):
147147
record.check_availability()
148148

149149

150-
def delete_record(pid, logger=None):
151-
"""Deletes a record."""
152-
logger.info("Ready to delete the object {pid}")
153-
record = RecordFilesWithIndex.get_record(pid.object_uuid)
154-
155-
for o in ObjectVersion.get_by_bucket(record.bucket).all():
156-
o.remove()
157-
FileInstance.query.filter_by(id=o.file_id).delete()
158-
FileIndexMetadata.delete_by_record(record=record)
159-
record.delete()
160-
return None
161-
162-
163150
def create_record(data, skip_files, logger=None):
164151
"""Creates a new record."""
165152
id = uuid.uuid4()

cernopendata/modules/globals/ext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import json
44
import logging
55
import os
6-
76
from counter_robots import is_robot_or_machine
87
from flask import Flask, request
98

9+
from cernopendata.modules.releases.utils import curator_experiments
1010
from cernopendata.version import __version__
1111

1212
logger = logging.getLogger(__name__)
@@ -51,6 +51,7 @@ def __init__(self, app):
5151
if not isinstance(app, Flask):
5252
return
5353

54+
app.context_processor(curator_experiments)
5455
self.set_experiments(app)
5556

5657
@staticmethod
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of CERN Open Data Portal.
4+
# Copyright (C) 2024 CERN.
5+
#
6+
# CERN Open Data Portal is free software; you can redistribute it
7+
# and/or modify it under the terms of the GNU General Public License as
8+
# published by the Free Software Foundation; either version 2 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# CERN Open Data Portal is distributed in the hope that it will be
12+
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
# General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with CERN Open Data Portal; if not, write to the
18+
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19+
# MA 02111-1307, USA.
20+
#
21+
# In applying this license, CERN does not
22+
# waive the privileges and immunities granted to it by virtue of its status
23+
# as an Intergovernmental Organization or submit itself to any jurisdiction.
24+
25+
"""CERN Open Data Releases."""

0 commit comments

Comments
 (0)