oarepo-runtime 1.6.1__py3-none-any.whl → 1.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oarepo_runtime/cli/__init__.py +2 -0
- oarepo_runtime/ext.py +31 -4
- oarepo_runtime/proxies.py +2 -0
- oarepo_runtime/services/schema/rdm.py +13 -0
- oarepo_runtime/services/schema/rdm_ui.py +13 -0
- oarepo_runtime/services/schema/ui.py +9 -2
- {oarepo_runtime-1.6.1.dist-info → oarepo_runtime-1.7.0.dist-info}/METADATA +2 -1
- {oarepo_runtime-1.6.1.dist-info → oarepo_runtime-1.7.0.dist-info}/RECORD +12 -12
- {oarepo_runtime-1.6.1.dist-info → oarepo_runtime-1.7.0.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.6.1.dist-info → oarepo_runtime-1.7.0.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.6.1.dist-info → oarepo_runtime-1.7.0.dist-info}/licenses/LICENSE +0 -0
- {oarepo_runtime-1.6.1.dist-info → oarepo_runtime-1.7.0.dist-info}/top_level.txt +0 -0
oarepo_runtime/cli/__init__.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from .assets import assets
|
2
2
|
from .base import as_command, oarepo
|
3
|
+
from .cf import cf
|
3
4
|
from .check import check
|
4
5
|
from .configuration import configuration_command
|
5
6
|
from .fixtures import fixtures
|
@@ -17,4 +18,5 @@ __all__ = (
|
|
17
18
|
"fixtures",
|
18
19
|
"configuration_command",
|
19
20
|
"permissions",
|
21
|
+
"cf",
|
20
22
|
)
|
oarepo_runtime/ext.py
CHANGED
@@ -1,11 +1,32 @@
|
|
1
1
|
from functools import cached_property
|
2
2
|
|
3
|
+
import pytz
|
4
|
+
from flask import current_app, session
|
5
|
+
from invenio_accounts.models import User
|
3
6
|
from invenio_base.utils import obj_or_import_string
|
4
7
|
|
5
|
-
import oarepo_runtime.cli.cf # noqa, just to register
|
6
|
-
|
7
8
|
from .cli import oarepo as oarepo_cmd
|
8
9
|
from .datastreams.ext import OARepoDataStreamsExt
|
10
|
+
from .proxies import current_timezone
|
11
|
+
|
12
|
+
|
13
|
+
def set_timezone():
|
14
|
+
if "timezone" in session:
|
15
|
+
current_timezone.set(pytz.timezone(session["timezone"]))
|
16
|
+
else:
|
17
|
+
default_user_timezone = current_app.config.get("BABEL_DEFAULT_TIMEZONE")
|
18
|
+
if default_user_timezone:
|
19
|
+
current_timezone.set(pytz.timezone(default_user_timezone))
|
20
|
+
else:
|
21
|
+
current_timezone.set(None)
|
22
|
+
|
23
|
+
|
24
|
+
def on_identity_changed(sender, identity):
|
25
|
+
if "timezone" not in session and "_user_id" in session:
|
26
|
+
user = User.query.filter_by(id=session["_user_id"]).first()
|
27
|
+
if user and "timezone" in user.preferences:
|
28
|
+
session["timezone"] = user.preferences["timezone"]
|
29
|
+
set_timezone()
|
9
30
|
|
10
31
|
|
11
32
|
class OARepoRuntime(object):
|
@@ -24,6 +45,11 @@ class OARepoRuntime(object):
|
|
24
45
|
app.extensions["oarepo-datastreams"] = OARepoDataStreamsExt(app)
|
25
46
|
app.cli.add_command(oarepo_cmd)
|
26
47
|
|
48
|
+
from flask_principal import identity_changed
|
49
|
+
|
50
|
+
identity_changed.connect(on_identity_changed, self.app)
|
51
|
+
app.before_request(set_timezone)
|
52
|
+
|
27
53
|
@cached_property
|
28
54
|
def owner_entity_resolvers(self):
|
29
55
|
return [
|
@@ -33,9 +59,10 @@ class OARepoRuntime(object):
|
|
33
59
|
@cached_property
|
34
60
|
def rdm_excluded_components(self):
|
35
61
|
return [
|
36
|
-
obj_or_import_string(x)
|
62
|
+
obj_or_import_string(x)
|
63
|
+
for x in self.app.config.get("RDM_EXCLUDED_COMPONENTS", [])
|
37
64
|
]
|
38
|
-
|
65
|
+
|
39
66
|
def init_config(self, app):
|
40
67
|
"""Initialize configuration."""
|
41
68
|
from . import ext_config
|
oarepo_runtime/proxies.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
from flask import current_app
|
2
2
|
from werkzeug.local import LocalProxy
|
3
|
+
from contextvars import ContextVar
|
3
4
|
|
5
|
+
current_timezone = ContextVar('timezone') #idk how or exactly why to use the LocalProxy here
|
4
6
|
current_datastreams = LocalProxy(lambda: current_app.extensions["oarepo-datastreams"])
|
5
7
|
current_oarepo = LocalProxy(lambda: current_app.extensions["oarepo-runtime"])
|
6
8
|
"""Helper proxy to get the current datastreams."""
|
@@ -15,6 +15,8 @@ from marshmallow_utils.fields import (
|
|
15
15
|
from marshmallow_utils.fields.nestedattr import NestedAttribute
|
16
16
|
from marshmallow_utils.schemas.identifier import IdentifierSchema
|
17
17
|
|
18
|
+
from .i18n import MultilingualField
|
19
|
+
|
18
20
|
|
19
21
|
class RDMRecordMixin(ma.Schema):
|
20
22
|
versions = NestedAttribute(VersionsSchema, dump_only=True)
|
@@ -60,3 +62,14 @@ class RelatedRecordIdentifierField(IdentifierSet):
|
|
60
62
|
*args,
|
61
63
|
**kwargs
|
62
64
|
)
|
65
|
+
|
66
|
+
|
67
|
+
class RDMSubjectSchema(ma.Schema):
|
68
|
+
"""Subject ui schema."""
|
69
|
+
|
70
|
+
class Meta:
|
71
|
+
unknown = ma.RAISE
|
72
|
+
|
73
|
+
_id = ma.fields.String(data_key="id")
|
74
|
+
|
75
|
+
subject = MultilingualField()
|
@@ -4,6 +4,8 @@ from oarepo_vocabularies.services.ui_schema import VocabularyI18nStrUIField
|
|
4
4
|
|
5
5
|
from oarepo_runtime.services.schema.marshmallow import DictOnlySchema
|
6
6
|
|
7
|
+
from .i18n_ui import MultilingualUIField
|
8
|
+
|
7
9
|
|
8
10
|
class RDMIdentifierWithSchemaUISchema(ma.Schema):
|
9
11
|
scheme = ma.fields.String(
|
@@ -141,3 +143,14 @@ class RDMCreatorsUISchema(ma.Schema):
|
|
141
143
|
)
|
142
144
|
|
143
145
|
person_or_org = ma.fields.Nested(RDMPersonOrOrganizationUISchema())
|
146
|
+
|
147
|
+
|
148
|
+
class RDMSubjectUISchema(ma.Schema):
|
149
|
+
"""Subject ui schema."""
|
150
|
+
|
151
|
+
class Meta:
|
152
|
+
unknown = ma.RAISE
|
153
|
+
|
154
|
+
_id = ma.fields.String(data_key="id")
|
155
|
+
|
156
|
+
subject = MultilingualUIField()
|
@@ -100,11 +100,18 @@ class MultilayerFormatEDTF(BabelFormatField):
|
|
100
100
|
return super().parse(value, **kwargs)
|
101
101
|
raise ValueError("Not a valid date")
|
102
102
|
|
103
|
+
class TimezoneMixin: #i'm not sure about where this should be used
|
104
|
+
@property
|
105
|
+
def tzinfo(self):
|
106
|
+
from oarepo_runtime.proxies import current_timezone
|
107
|
+
try:
|
108
|
+
return current_timezone.get()
|
109
|
+
except LookupError:
|
110
|
+
return
|
103
111
|
|
104
|
-
class LocalizedDateTime(LocalizedMixin, FormatDatetime):
|
112
|
+
class LocalizedDateTime(TimezoneMixin, LocalizedMixin, FormatDatetime):
|
105
113
|
pass
|
106
114
|
|
107
|
-
|
108
115
|
class LocalizedTime(LocalizedMixin, FormatTimeString):
|
109
116
|
pass
|
110
117
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oarepo-runtime
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.7.0
|
4
4
|
Summary: A set of runtime extensions of Invenio repository
|
5
5
|
Description-Content-Type: text/markdown
|
6
6
|
License-File: LICENSE
|
@@ -21,6 +21,7 @@ Requires-Dist: autoflake; extra == "dev"
|
|
21
21
|
Requires-Dist: oarepo-tools; extra == "dev"
|
22
22
|
Provides-Extra: tests
|
23
23
|
Requires-Dist: pytest>=7.1.2; extra == "tests"
|
24
|
+
Requires-Dist: pytest-oarepo; extra == "tests"
|
24
25
|
Requires-Dist: psutil; extra == "tests"
|
25
26
|
Dynamic: license-file
|
26
27
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
oarepo_runtime/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
oarepo_runtime/config.py,sha256=nf3hqcldk4-ixswZqIDHgX3EvNRiOlNdkavPz_RUkqw,601
|
3
|
-
oarepo_runtime/ext.py,sha256=
|
3
|
+
oarepo_runtime/ext.py,sha256=BcKI63tMxHd3tqx3CBqCQhQiBo27GvevQxuQMd606qg,3476
|
4
4
|
oarepo_runtime/ext_config.py,sha256=ERpi6uJqDE6OpqebB_vuusmoB3xaAziuKeGVxVI5Q-w,2155
|
5
5
|
oarepo_runtime/profile.py,sha256=QzrQoZncjoN74ZZnpkEKakNk08KCzBU7m6y42RN8AMY,1637
|
6
|
-
oarepo_runtime/proxies.py,sha256=
|
6
|
+
oarepo_runtime/proxies.py,sha256=q32CkxxF55xEZKexztnK_EQh6x6ke0ns8p5Cpxtp73c,413
|
7
7
|
oarepo_runtime/tasks.py,sha256=AciXN1fUq6tzfzNSICh1S6XoHGWiuH76bUqXyzTsOPU,140
|
8
8
|
oarepo_runtime/uow.py,sha256=iyF3R2oCPSVUu38GXoxZallgRD-619q1fWTb8sSaeyQ,4412
|
9
|
-
oarepo_runtime/cli/__init__.py,sha256=
|
9
|
+
oarepo_runtime/cli/__init__.py,sha256=SM_bMRWDfNAuNElDGTvLkIEe2vpKOSBYICH6IHxxAIk,458
|
10
10
|
oarepo_runtime/cli/assets.py,sha256=ZG80xIOKch7rsU_7QlvZxBQAXNQ9ow5xLsUREsl5MEE,4076
|
11
11
|
oarepo_runtime/cli/base.py,sha256=94RBTa8TOSPxEyEUmYLGXaWen-XktP2-MIbTtZSlCZo,544
|
12
12
|
oarepo_runtime/cli/cf.py,sha256=W0JEJK2JqKubQw8qtZJxohmADDRUBode4JZAqYLDGvc,339
|
@@ -136,9 +136,9 @@ oarepo_runtime/services/schema/marshmallow.py,sha256=iAMMH5MlYs59qetXAHOROvERNSc
|
|
136
136
|
oarepo_runtime/services/schema/marshmallow_to_json_schema.py,sha256=VYLnVWHOoaxWCD_gqJO8-8u1SbaPEFBjDZ5HGgGr0Ow,2027
|
137
137
|
oarepo_runtime/services/schema/oneofschema.py,sha256=GnWH4Or_G5M0NgSmCoqMI6PBrJg5AC9RHrcB5QDKRq0,6661
|
138
138
|
oarepo_runtime/services/schema/polymorphic.py,sha256=bAbUoTIeDBiJPYPhpLEKKZekEdkHlpqkmNxk1hN3PDw,564
|
139
|
-
oarepo_runtime/services/schema/rdm.py,sha256=
|
140
|
-
oarepo_runtime/services/schema/rdm_ui.py,sha256=
|
141
|
-
oarepo_runtime/services/schema/ui.py,sha256=
|
139
|
+
oarepo_runtime/services/schema/rdm.py,sha256=rtyO46CREmBJMQxgm0UenIbELSY6OAj35VbxFflIH_g,2272
|
140
|
+
oarepo_runtime/services/schema/rdm_ui.py,sha256=ffjl20tvRcuX3FNINOhGJWX84aTNEzJOqoKZum1s03s,3778
|
141
|
+
oarepo_runtime/services/schema/ui.py,sha256=ff2AfK-G0fArlVHHKsDagPhu9NkMj6DPcVK4NycEO8c,8216
|
142
142
|
oarepo_runtime/services/schema/validation.py,sha256=aRfeR-2D1XXYqI3_U5FHoFvJrYjZlpM8nB35-M_u3Qs,2300
|
143
143
|
oarepo_runtime/translations/default_translations.py,sha256=060GBlA1ghWxfeumo6NqxCCZDb-6OezOuF6pr-_GEOQ,104
|
144
144
|
oarepo_runtime/translations/messages.pot,sha256=wr1vDKjsngqS9e5zQmSAsF3qUAtpQ41SUXwzEKRCnWw,2406
|
@@ -149,13 +149,13 @@ oarepo_runtime/translations/en/LC_MESSAGES/messages.po,sha256=7-5S3iINOSFSI5gVdR
|
|
149
149
|
oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
150
150
|
oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
|
151
151
|
oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
|
152
|
-
oarepo_runtime-1.
|
152
|
+
oarepo_runtime-1.7.0.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
153
153
|
tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
154
154
|
tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
|
155
155
|
tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
|
156
156
|
tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
157
|
-
oarepo_runtime-1.
|
158
|
-
oarepo_runtime-1.
|
159
|
-
oarepo_runtime-1.
|
160
|
-
oarepo_runtime-1.
|
161
|
-
oarepo_runtime-1.
|
157
|
+
oarepo_runtime-1.7.0.dist-info/METADATA,sha256=NUTpowtktIjmv9Wws8RahuI0nXprG3FGS_O7IKOjI80,4788
|
158
|
+
oarepo_runtime-1.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
159
|
+
oarepo_runtime-1.7.0.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
|
160
|
+
oarepo_runtime-1.7.0.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
161
|
+
oarepo_runtime-1.7.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|