Skip to content

Commit

Permalink
config: document extended metadata
Browse files Browse the repository at this point in the history
- travis config 
- config: document extended metadata
- config: ui document extenede metadata
- closes #98
  • Loading branch information
topless committed Jun 17, 2020
1 parent 6174b21 commit caf1804
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ env:
global:
- ES7_DOWNLOAD_URL="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.0-linux-x86_64.tar.gz"
- ES_HOST=127.0.0.1
- PIPENV_PYUP_API_KEY=""

python:
- "3.6"
Expand Down
2 changes: 1 addition & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions cds_books/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

from invenio_app_ils.config import RECORDS_REST_ENDPOINTS
from invenio_app_ils.pidstore.pids import PATRON_PID_TYPE
from invenio_records_rest.schemas.fields import SanitizedUnicode
from marshmallow.fields import Bool

from .literature.covers import build_syndetic_cover_urls
from .patrons.api import Patron
Expand Down Expand Up @@ -243,3 +245,69 @@ def _parse_env_bool(var_name, default=None):
"invenio_opendefinition"]

ILS_LITERATURE_COVER_URLS_BUILDER = build_syndetic_cover_urls

# Namespaces for fields added to the metadata schema
ILS_RECORDS_METADATA_NAMESPACES = {
"document": {
"accelerator_experiments": {
"@context": "https://test.org/accelerator_experiments/terms"
},
"standard_CERN_status": {
"@context": "https://test.org/standard_CERN_status/terms"
},
}
}

# Fields added to the metadata schema.
ILS_RECORDS_METADATA_EXTENSIONS = {
"document": {
"accelerator_experiments:accelerator": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
"accelerator_experiments:curated_relation": {
"elasticsearch": "boolean",
"marshmallow": Bool()
},
"accelerator_experiments:experiment": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
"accelerator_experiments:institution": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
"accelerator_experiments:legacy_name": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
"accelerator_experiments:project": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
"accelerator_experiments:study": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
"standard_CERN_status:CERN_applicability": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
"standard_CERN_status:standard_validity": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode(required=True)
},
"standard_CERN_status:checkdate": {
"elasticsearch": "date",
"marshmallow": SanitizedUnicode()
},
"standard_CERN_status:comment": {
"elasticsearch": "text",
"marshmallow": SanitizedUnicode()
},
"standard_CERN_status:expert": {
"elasticsearch": "keyword",
"marshmallow": SanitizedUnicode()
},
}
}
78 changes: 78 additions & 0 deletions ui/config/extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import _keys from 'lodash/keys';

const fields = {
'accelerator_experiments:accelerator': {
label: 'Accelerator',
type: 'string',
default: '',
},
'accelerator_experiments:curated_relation': {
label: 'Curated Relation',
type: 'boolean',
default: false,
},
'accelerator_experiments:experiment': {
label: 'Experiment',
type: 'string',
default: '',
},
'accelerator_experiments:institution': {
label: 'Institution',
type: 'string',
default: '',
},
'accelerator_experiments:legacy_name': {
label: 'Legacy Name',
type: 'string',
default: '',
},
'accelerator_experiments:project': {
label: 'Project',
type: 'string',
default: '',
},
'accelerator_experiments:study': {
label: 'Study',
type: 'string',
default: '',
},
'standard_CERN_status:CERN_applicability': {
label: 'Status CERN Applicability',
type: 'string',
default: '',
},
'standard_CERN_status:standard_validity': {
label: 'Status Standard Validity',
type: 'string',
default: '',
isRequired: true,
},
'standard_CERN_status:checkdate': {
label: 'Status check date',
type: 'date',
default: '',
},
'standard_CERN_status:comment': {
label: 'Status comment',
type: 'string',
default: '',
},
'standard_CERN_status:expert': {
label: 'Status expert',
type: 'string',
default: '',
},
};

const defaults = () => {
const keys = _keys(fields);
let result = {};
keys.map(key => (result[key] = fields[key]['default']));
return result;
};

export const extensionsConfig = {
label: 'Other',
fields: fields,
defaults: defaults,
};
5 changes: 5 additions & 0 deletions ui/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { extensionsConfig } from './extensions';

export const config = {
extensions: extensionsConfig,
};
3 changes: 2 additions & 1 deletion ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'react-app-polyfill/ie11'; // For IE 11 support
import ReactDOM from 'react-dom';
import { OverridableContext } from 'react-overridable';
import 'semantic-ui-less/semantic.less';
import { config } from '../config';

const CustomHome = ({ ...props }) => {
return <>CERN Library Catalogue</>;
Expand All @@ -15,7 +16,7 @@ const overriddenCmps = {

ReactDOM.render(
<OverridableContext.Provider value={overriddenCmps}>
<InvenioILSApp />
<InvenioILSApp config={config} />
</OverridableContext.Provider>,
document.getElementById('app')
);

0 comments on commit caf1804

Please sign in to comment.