oarepo-runtime 1.4.13__tar.gz → 1.4.15__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. {oarepo-runtime-1.4.13/oarepo_runtime.egg-info → oarepo-runtime-1.4.15}/PKG-INFO +1 -1
  2. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cf/__init__.py +1 -1
  3. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cf/cli.py +0 -1
  4. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cf/mappings.py +2 -2
  5. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/facets/base.py +3 -0
  6. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/facets/date.py +14 -11
  7. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/i18n/ui_schema.py +2 -8
  8. oarepo-runtime-1.4.15/oarepo_runtime/records/__init__.py +1 -0
  9. oarepo-runtime-1.4.15/oarepo_runtime/records/systemfields/__init__.py +10 -0
  10. {oarepo-runtime-1.4.13/oarepo_runtime/records → oarepo-runtime-1.4.15/oarepo_runtime/records/systemfields}/icu.py +1 -1
  11. oarepo-runtime-1.4.15/oarepo_runtime/resources/__init__.py +3 -0
  12. oarepo-runtime-1.4.15/oarepo_runtime/resources/localized_ui_json_serializer.py +41 -0
  13. oarepo-runtime-1.4.15/oarepo_runtime/services/schema/__init__.py +3 -0
  14. oarepo-runtime-1.4.15/oarepo_runtime/services/schema/cf.py +13 -0
  15. oarepo-runtime-1.4.13/oarepo_runtime/ui/marshmallow.py → oarepo-runtime-1.4.15/oarepo_runtime/services/schema/ui.py +41 -18
  16. oarepo-runtime-1.4.13/oarepo_runtime/services/icu.py → oarepo-runtime-1.4.15/oarepo_runtime/services/search.py +1 -1
  17. oarepo-runtime-1.4.15/oarepo_runtime/ui/marshmallow.py +9 -0
  18. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15/oarepo_runtime.egg-info}/PKG-INFO +1 -1
  19. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime.egg-info/SOURCES.txt +12 -7
  20. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime.egg-info/entry_points.txt +1 -1
  21. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/setup.cfg +2 -2
  22. oarepo-runtime-1.4.13/oarepo_runtime/validation/__init__.py +0 -3
  23. oarepo-runtime-1.4.13/tests/pkg_data/__init__.py +0 -0
  24. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/LICENSE +0 -0
  25. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/MANIFEST.in +0 -0
  26. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/README.md +0 -0
  27. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/__init__.py +0 -0
  28. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cli/__init__.py +0 -0
  29. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cli/assets.py +0 -0
  30. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cli/base.py +0 -0
  31. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cli/check.py +0 -0
  32. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cli/index.py +0 -0
  33. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/cli/validate.py +0 -0
  34. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/config/__init__.py +0 -0
  35. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/config/permissions_presets.py +0 -0
  36. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/config/service.py +0 -0
  37. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/__init__.py +0 -0
  38. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/batch.py +0 -0
  39. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/catalogue.py +0 -0
  40. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/cli.py +0 -0
  41. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/config.py +0 -0
  42. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/datastreams.py +0 -0
  43. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/errors.py +0 -0
  44. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/fixtures.py +0 -0
  45. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
  46. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/readers/attachments.py +0 -0
  47. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/readers/excel.py +0 -0
  48. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/readers/json.py +0 -0
  49. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/readers/service.py +0 -0
  50. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
  51. /oarepo-runtime-1.4.13/oarepo_runtime/tasks/datastreams.py → /oarepo-runtime-1.4.15/oarepo_runtime/datastreams/tasks.py +0 -0
  52. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/transformers.py +0 -0
  53. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/utils.py +0 -0
  54. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
  55. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/writers/attachment.py +0 -0
  56. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/writers/service.py +0 -0
  57. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/writers/validation_errors.py +0 -0
  58. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
  59. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/drafts/__init__.py +0 -0
  60. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/drafts/systemfields/__init__.py +0 -0
  61. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/drafts/systemfields/has_draftcheck.py +0 -0
  62. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/expansions/__init__.py +0 -0
  63. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/expansions/expandable_fields.py +0 -0
  64. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/expansions/service.py +0 -0
  65. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/ext.py +0 -0
  66. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/ext_config.py +0 -0
  67. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/facets/__init__.py +0 -0
  68. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/facets/enum.py +0 -0
  69. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/facets/max_facet.py +0 -0
  70. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/facets/nested_facet.py +0 -0
  71. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/facets/params.py +0 -0
  72. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/i18n/__init__.py +0 -0
  73. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/i18n/default_translations.py +0 -0
  74. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/i18n/dumper.py +0 -0
  75. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/i18n/schema.py +0 -0
  76. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/i18n/validation.py +0 -0
  77. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/marshmallow.py +0 -0
  78. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/profile.py +0 -0
  79. /oarepo-runtime-1.4.13/oarepo_runtime/records/__init__.py → /oarepo-runtime-1.4.15/oarepo_runtime/records/systemfields/mapping.py +0 -0
  80. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/__init__.py +0 -0
  81. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/base.py +0 -0
  82. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/components.py +0 -0
  83. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/errors.py +0 -0
  84. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/internal.py +0 -0
  85. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/lookup.py +0 -0
  86. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/mapping.py +0 -0
  87. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/pid_relation.py +0 -0
  88. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/relations/uow.py +0 -0
  89. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/resolvers/__init__.py +0 -0
  90. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/resolvers/proxies.py +0 -0
  91. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/services/__init__.py +0 -0
  92. {oarepo-runtime-1.4.13/oarepo_runtime → oarepo-runtime-1.4.15/oarepo_runtime/services/schema}/polymorphic.py +0 -0
  93. /oarepo-runtime-1.4.13/oarepo_runtime/validation/dates.py → /oarepo-runtime-1.4.15/oarepo_runtime/services/schema/validation.py +0 -0
  94. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
  95. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -0
  96. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -0
  97. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/translations/messages.pot +0 -0
  98. {oarepo-runtime-1.4.13/oarepo_runtime/tasks → oarepo-runtime-1.4.15/oarepo_runtime/ui}/__init__.py +0 -0
  99. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/uow.py +0 -0
  100. {oarepo-runtime-1.4.13/oarepo_runtime/ui → oarepo-runtime-1.4.15/oarepo_runtime/utils}/__init__.py +0 -0
  101. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime/utils/path.py +0 -0
  102. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
  103. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime.egg-info/requires.txt +0 -0
  104. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/oarepo_runtime.egg-info/top_level.txt +0 -0
  105. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/pyproject.toml +0 -0
  106. {oarepo-runtime-1.4.13 → oarepo-runtime-1.4.15}/setup.py +0 -0
  107. {oarepo-runtime-1.4.13/oarepo_runtime/utils → oarepo-runtime-1.4.15/tests/pkg_data}/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.4.13
3
+ Version: 1.4.15
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ from flask import current_app
4
4
  from invenio_records.systemfields import DictField, SystemField
5
5
  from invenio_records_resources.services.custom_fields import BaseCF
6
6
 
7
- from oarepo_runtime.records import MappingSystemFieldMixin
7
+ from oarepo_runtime.records.systemfields.mapping import MappingSystemFieldMixin
8
8
 
9
9
 
10
10
  class CustomFieldsMixin(MappingSystemFieldMixin):
@@ -1,4 +1,3 @@
1
- import click
2
1
  from flask.cli import with_appcontext
3
2
 
4
3
  from oarepo_runtime.cli import oarepo
@@ -1,5 +1,5 @@
1
1
  import inspect
2
- from typing import Iterable, List
2
+ from typing import Iterable
3
3
 
4
4
  import click
5
5
  import deepmerge
@@ -13,7 +13,7 @@ from invenio_search import current_search_client
13
13
  from invenio_search.engine import dsl, search
14
14
  from invenio_search.utils import build_alias_name
15
15
 
16
- from oarepo_runtime.records import MappingSystemFieldMixin
16
+ from oarepo_runtime.records.systemfields.mapping import MappingSystemFieldMixin
17
17
 
18
18
 
19
19
  class Mapping(InvenioMapping):
@@ -5,5 +5,8 @@ class LabelledValuesTermsFacet(TermsFacet):
5
5
  def __init__(self, *args, **kwargs):
6
6
  super().__init__(*args, **{"value_labels": self.value_labels, **kwargs})
7
7
 
8
+ def localized_value_labels(self, values, locale):
9
+ return {val: val for val in values}
10
+
8
11
  def value_labels(self, values):
9
12
  return {val: val for val in values}
@@ -3,7 +3,7 @@ import re
3
3
  from invenio_records_resources.services.records.facets.facets import LabelledFacetMixin
4
4
  from invenio_search.engine import dsl
5
5
 
6
- from oarepo_runtime.ui.marshmallow import (
6
+ from oarepo_runtime.services.schema.ui import (
7
7
  LocalizedDate,
8
8
  LocalizedDateTime,
9
9
  LocalizedEDTF,
@@ -15,24 +15,27 @@ from .base import LabelledValuesTermsFacet
15
15
 
16
16
 
17
17
  class DateFacet(LabelledValuesTermsFacet):
18
- def value_labels(self, values):
19
- return {val: LocalizedDate().format_value(val) for val in values}
18
+ def localized_value_labels(self, values, locale):
19
+ return {val: LocalizedDate(locale=locale).format_value(val) for val in values}
20
20
 
21
21
 
22
22
  class TimeFacet(LabelledValuesTermsFacet):
23
- def value_labels(self, values):
24
- return {val: LocalizedTime().format_value(val) for val in values}
23
+ def localized_value_labels(self, values, locale):
24
+ return {val: LocalizedTime(locale=locale).format_value(val) for val in values}
25
25
 
26
26
 
27
27
  class DateTimeFacet(LabelledValuesTermsFacet):
28
- def value_labels(self, values):
29
- return {val: LocalizedDateTime().format_value(val) for val in values}
28
+ def localized_value_labels(self, values, locale):
29
+ return {
30
+ val: LocalizedDateTime(locale=locale).format_value(val) for val in values
31
+ }
30
32
 
31
33
 
32
34
  class EDTFFacet(LabelledValuesTermsFacet):
33
- def value_labels(self, values):
35
+ def localized_value_labels(self, values, locale):
34
36
  return {
35
- val: LocalizedEDTF().format_value(convert_to_edtf(val)) for val in values
37
+ val: LocalizedEDTF(locale=locale).format_value(convert_to_edtf(val))
38
+ for val in values
36
39
  }
37
40
 
38
41
 
@@ -51,9 +54,9 @@ class EDTFIntervalFacet(LabelledFacetMixin, AutoDateHistogramFacet):
51
54
  # kwargs["interval"] = "year"
52
55
  super().__init__(*args, **kwargs)
53
56
 
54
- def value_labels(self, values):
57
+ def localized_value_labels(self, values, locale):
55
58
  return {
56
- val: LocalizedEDTFInterval().format_value(convert_to_edtf(val))
59
+ val: LocalizedEDTFInterval(locale=locale).format_value(convert_to_edtf(val))
57
60
  for val in values
58
61
  }
59
62
 
@@ -1,7 +1,5 @@
1
1
  from functools import lru_cache
2
2
 
3
- from flask import current_app
4
- from flask_babelex import get_locale
5
3
  from marshmallow import Schema, fields
6
4
 
7
5
 
@@ -40,13 +38,9 @@ def get_i18n_localized_ui_schema(lang_field, value_field):
40
38
  def _serialize(self, value, attr=None, obj=None, **kwargs):
41
39
  if not value:
42
40
  return None
43
- locale = get_locale().language
41
+ language = self.context["locale"].language
44
42
  for v in value:
45
- if locale == v[lang_field]:
46
- return v[value_field]
47
- locale = current_app.config["BABEL_DEFAULT_LOCALE"]
48
- for v in value:
49
- if locale == v[lang_field]:
43
+ if language == v[lang_field]:
50
44
  return v[value_field]
51
45
  return next(iter(value))[value_field]
52
46
 
@@ -0,0 +1,10 @@
1
+ from .icu import ICUField, ICUSuggestField, ICUSortField
2
+ from .mapping import MappingSystemFieldMixin, SystemFieldDumperExt
3
+
4
+ __all__ = (
5
+ "ICUField",
6
+ "ICUSuggestField",
7
+ "ICUSortField",
8
+ "MappingSystemFieldMixin",
9
+ "SystemFieldDumperExt",
10
+ )
@@ -4,7 +4,7 @@ from typing import Dict
4
4
  from flask import current_app
5
5
  from invenio_records.systemfields import SystemField
6
6
 
7
- from oarepo_runtime.records import MappingSystemFieldMixin
7
+ from oarepo_runtime.records.systemfields.mapping import MappingSystemFieldMixin
8
8
  from oarepo_runtime.relations.lookup import lookup_key
9
9
 
10
10
 
@@ -0,0 +1,3 @@
1
+ from .localized_ui_json_serializer import LocalizedUIJSONSerializer
2
+
3
+ __all__ = ("LocalizedUIJSONSerializer",)
@@ -0,0 +1,41 @@
1
+ from flask_babelex import get_locale
2
+ from flask_resources import MarshmallowSerializer
3
+
4
+
5
+ class LocalizedUIJSONSerializer(MarshmallowSerializer):
6
+ def __init__(
7
+ self,
8
+ format_serializer_cls,
9
+ object_schema_cls,
10
+ list_schema_cls=None,
11
+ schema_context=None,
12
+ **serializer_options,
13
+ ):
14
+ super().__init__(
15
+ format_serializer_cls=format_serializer_cls,
16
+ object_schema_cls=object_schema_cls,
17
+ list_schema_cls=list_schema_cls,
18
+ schema_context=schema_context or {},
19
+ **serializer_options,
20
+ )
21
+
22
+ def dump_obj(self, obj):
23
+ """Dump the object using object schema class."""
24
+ return self.object_schema_cls(
25
+ context={**self.schema_context, "locale": get_locale()}
26
+ ).dump(obj)
27
+
28
+ def dump_list(self, obj_list):
29
+ """Dump the list of objects."""
30
+ ctx = {
31
+ "object_schema_cls": self.object_schema_cls,
32
+ }
33
+ ctx.update(self.schema_context)
34
+ ctx["locale"] = get_locale()
35
+
36
+ if self.list_schema_cls is None:
37
+ return self.object_schema_cls(context=self.schema_context).dump(
38
+ obj_list, many=True
39
+ )
40
+
41
+ return self.list_schema_cls(context=ctx).dump(obj_list)
@@ -0,0 +1,3 @@
1
+ from .polymorphic import PolymorphicSchema
2
+
3
+ __all__ = ("PolymorphicSchema",)
@@ -0,0 +1,13 @@
1
+ from invenio_records_resources.services.custom_fields.schema import (
2
+ CustomFieldsSchemaUI as InvenioCustomFieldsSchemaUI,
3
+ )
4
+
5
+
6
+ class CustomFieldsSchemaUI(InvenioCustomFieldsSchemaUI):
7
+ def _serialize(self, obj, **kwargs):
8
+ self._schema.context.update(self.context)
9
+ return super()._serialize(obj, **kwargs)
10
+
11
+ def _deserialize(self, data, **kwargs):
12
+ self._schema.context.update(self.context)
13
+ return super()._deserialize(data, **kwargs)
@@ -1,12 +1,11 @@
1
1
  import datetime
2
2
  import re
3
- from functools import partial
4
3
 
5
4
  import marshmallow as ma
6
5
  from babel.dates import format_date
7
6
  from babel_edtf import format_edtf
8
7
  from flask import current_app
9
- from flask_babelex import get_locale, gettext
8
+ from flask_babelex import gettext
10
9
  from marshmallow_utils.fields import (
11
10
  BabelGettextDictField,
12
11
  FormatDate,
@@ -25,8 +24,23 @@ def current_default_locale():
25
24
  return "en"
26
25
 
27
26
 
27
+ class LocalizedMixin:
28
+ def __init__(self, *args, locale=None, **kwargs):
29
+ super().__init__(*args, locale=locale, **kwargs)
30
+
31
+ @property
32
+ def locale(self):
33
+ if self._locale:
34
+ return self._locale
35
+ if self.parent:
36
+ if "locale" in self.context:
37
+ return self.context["locale"]
38
+ return current_default_locale()
39
+
40
+
28
41
  # localized date field
29
- LocalizedDate = partial(FormatDate, locale=get_locale)
42
+ class LocalizedDate(LocalizedMixin, FormatDate):
43
+ pass
30
44
 
31
45
 
32
46
  class FormatTimeString(FormatTime):
@@ -54,18 +68,27 @@ class MultilayerFormatEDTF(BabelFormatField):
54
68
  except:
55
69
  return format_edtf(value, format=self._format, locale=self.locale)
56
70
 
71
+ def parse(self, value, **kwargs):
72
+ # standard parsing is too lenient, for example returns "2000-01-01" for input "2000"
73
+ if re.match("^[0-9]+-[0-9]+-[0-9]+", value):
74
+ return super().parse(value, **kwargs)
75
+ raise ValueError("Not a valid date")
76
+
77
+
78
+ class LocalizedDateTime(LocalizedMixin, FormatDatetime):
79
+ pass
57
80
 
58
- # localized edtf
59
- LocalizedEDTF = partial(MultilayerFormatEDTF, locale=get_locale)
60
81
 
61
- # localized time field
62
- LocalizedTime = partial(FormatTimeString, locale=get_locale)
82
+ class LocalizedTime(LocalizedMixin, FormatTimeString):
83
+ pass
63
84
 
64
- # localized datetime field
65
- LocalizedDateTime = partial(FormatDatetime, locale=get_locale)
66
85
 
67
- # localized edtf interval uses the same class as plain EDTF
68
- LocalizedEDTFInterval = partial(FormatEDTF, locale=get_locale)
86
+ class LocalizedEDTF(LocalizedMixin, MultilayerFormatEDTF):
87
+ pass
88
+
89
+
90
+ class LocalizedEDTFInterval(LocalizedMixin, FormatEDTF):
91
+ pass
69
92
 
70
93
 
71
94
  class PrefixedGettextField(BabelGettextDictField):
@@ -79,16 +102,16 @@ class PrefixedGettextField(BabelGettextDictField):
79
102
  return gettext(value)
80
103
 
81
104
 
82
- LocalizedEnum = partial(
83
- PrefixedGettextField,
84
- # value_prefix will come from the outside
85
- locale=get_locale,
86
- default_locale=current_default_locale,
87
- )
105
+ class LocalizedEnum(LocalizedMixin, PrefixedGettextField):
106
+ pass
107
+
108
+ def __init__(self, **kwargs):
109
+ super().__init__(default_locale=current_default_locale, **kwargs)
110
+
88
111
 
89
112
  if False: # NOSONAR
90
113
  # just for the makemessages to pick up the translations
91
- translations = [_("True"), _("True")]
114
+ translations = [_("True"), _("False")]
92
115
 
93
116
 
94
117
  class InvenioUISchema(ma.Schema):
@@ -10,7 +10,7 @@ from invenio_records_resources.services.records import (
10
10
  )
11
11
  from invenio_records_resources.services.records.queryparser import SuggestQueryParser
12
12
 
13
- from oarepo_runtime.records.icu import ICUSuggestField
13
+ from oarepo_runtime.records.systemfields.icu import ICUSuggestField
14
14
 
15
15
  try:
16
16
  from invenio_i18n import get_locale
@@ -0,0 +1,9 @@
1
+ from oarepo_runtime.services.schema.ui import InvenioUISchema
2
+ import warnings
3
+
4
+ warnings.warn(
5
+ "Deprecated, please use oarepo_runtime.services.schema.ui.InvenioUISchema",
6
+ DeprecationWarning,
7
+ )
8
+
9
+ __all__ = ("InvenioUISchema",)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.4.13
3
+ Version: 1.4.15
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -8,7 +8,6 @@ oarepo_runtime/__init__.py
8
8
  oarepo_runtime/ext.py
9
9
  oarepo_runtime/ext_config.py
10
10
  oarepo_runtime/marshmallow.py
11
- oarepo_runtime/polymorphic.py
12
11
  oarepo_runtime/profile.py
13
12
  oarepo_runtime/uow.py
14
13
  oarepo_runtime.egg-info/PKG-INFO
@@ -37,6 +36,7 @@ oarepo_runtime/datastreams/config.py
37
36
  oarepo_runtime/datastreams/datastreams.py
38
37
  oarepo_runtime/datastreams/errors.py
39
38
  oarepo_runtime/datastreams/fixtures.py
39
+ oarepo_runtime/datastreams/tasks.py
40
40
  oarepo_runtime/datastreams/transformers.py
41
41
  oarepo_runtime/datastreams/utils.py
42
42
  oarepo_runtime/datastreams/readers/__init__.py
@@ -70,7 +70,9 @@ oarepo_runtime/i18n/schema.py
70
70
  oarepo_runtime/i18n/ui_schema.py
71
71
  oarepo_runtime/i18n/validation.py
72
72
  oarepo_runtime/records/__init__.py
73
- oarepo_runtime/records/icu.py
73
+ oarepo_runtime/records/systemfields/__init__.py
74
+ oarepo_runtime/records/systemfields/icu.py
75
+ oarepo_runtime/records/systemfields/mapping.py
74
76
  oarepo_runtime/relations/__init__.py
75
77
  oarepo_runtime/relations/base.py
76
78
  oarepo_runtime/relations/components.py
@@ -82,10 +84,15 @@ oarepo_runtime/relations/pid_relation.py
82
84
  oarepo_runtime/relations/uow.py
83
85
  oarepo_runtime/resolvers/__init__.py
84
86
  oarepo_runtime/resolvers/proxies.py
87
+ oarepo_runtime/resources/__init__.py
88
+ oarepo_runtime/resources/localized_ui_json_serializer.py
85
89
  oarepo_runtime/services/__init__.py
86
- oarepo_runtime/services/icu.py
87
- oarepo_runtime/tasks/__init__.py
88
- oarepo_runtime/tasks/datastreams.py
90
+ oarepo_runtime/services/search.py
91
+ oarepo_runtime/services/schema/__init__.py
92
+ oarepo_runtime/services/schema/cf.py
93
+ oarepo_runtime/services/schema/polymorphic.py
94
+ oarepo_runtime/services/schema/ui.py
95
+ oarepo_runtime/services/schema/validation.py
89
96
  oarepo_runtime/translations/messages.pot
90
97
  oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo
91
98
  oarepo_runtime/translations/cs/LC_MESSAGES/messages.po
@@ -94,6 +101,4 @@ oarepo_runtime/ui/__init__.py
94
101
  oarepo_runtime/ui/marshmallow.py
95
102
  oarepo_runtime/utils/__init__.py
96
103
  oarepo_runtime/utils/path.py
97
- oarepo_runtime/validation/__init__.py
98
- oarepo_runtime/validation/dates.py
99
104
  tests/pkg_data/__init__.py
@@ -5,4 +5,4 @@ oarepo_runtime = oarepo_runtime.ext:OARepoRuntime
5
5
  oarepo_runtime = oarepo_runtime.ext:OARepoRuntime
6
6
 
7
7
  [invenio_celery.tasks]
8
- oarepo_runtime_datastreams = oarepo_runtime.tasks.datastreams
8
+ oarepo_runtime_datastreams = oarepo_runtime.datastreams.tasks
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = oarepo-runtime
3
- version = 1.4.13
3
+ version = 1.4.15
4
4
  description = A set of runtime extensions of Invenio repository
5
5
  authors = Alzbeta Pokorna
6
6
  readme = README.md
@@ -59,7 +59,7 @@ invenio_base.apps =
59
59
  invenio_base.api_apps =
60
60
  oarepo_runtime = oarepo_runtime.ext:OARepoRuntime
61
61
  invenio_celery.tasks =
62
- oarepo_runtime_datastreams = oarepo_runtime.tasks.datastreams
62
+ oarepo_runtime_datastreams = oarepo_runtime.datastreams.tasks
63
63
 
64
64
  [egg_info]
65
65
  tag_build =
@@ -1,3 +0,0 @@
1
- from .dates import CachedMultilayerEDTFValidator, validate_date, validate_datetime
2
-
3
- __all__ = ["validate_date", "validate_datetime", "CachedMultilayerEDTFValidator"]
File without changes
File without changes