Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search: Replace AND default operator by OR. #401

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
can_create_organisation_records_factory, \
can_delete_organisation_records_factory, \
can_update_organisation_records_factory, \
librarian_delete_permission_factory, librarian_permission_factory
librarian_delete_permission_factory, librarian_permission_factory, \
librarian_update_permission_factory


def _(x):
Expand Down Expand Up @@ -321,7 +322,7 @@ def _(x):
RECORDS_REST_DEFAULT_READ_PERMISSION_FACTORY = librarian_permission_factory
"""Default read permission factory: check if the record exists."""

RECORDS_REST_DEFAULT_UPDATE_PERMISSION_FACTORY = librarian_permission_factory
RECORDS_REST_DEFAULT_UPDATE_PERMISSION_FACTORY = librarian_update_permission_factory
"""Default update permission factory: reject any request."""

RECORDS_REST_DEFAULT_DELETE_PERMISSION_FACTORY = librarian_delete_permission_factory
Expand Down Expand Up @@ -363,7 +364,7 @@ def _(x):
# ),
default_media_type='application/json',
max_result_window=5000000,
search_factory_imp='rero_ils.query:and_search_factory',
search_factory_imp='rero_ils.query:search_factory',
read_permission_factory_imp=allow_all,
list_permission_factory_imp=allow_all
),
Expand Down Expand Up @@ -522,7 +523,7 @@ def _(x):
item_route='/organisations/<pid(org, record_class="rero_ils.modules.organisations.api:Organisation"):pid_value>',
default_media_type='application/json',
max_result_window=10000,
search_factory_imp='rero_ils.query:and_search_factory',
search_factory_imp='rero_ils.query:search_factory',
create_permission_factory_imp=deny_all,
update_permission_factory_imp=deny_all,
delete_permission_factory_imp=deny_all,
Expand Down Expand Up @@ -615,7 +616,7 @@ def _(x):
item_route='/persons/<pid(pers, record_class="rero_ils.modules.mef_persons.api:MefPerson"):pid_value>',
default_media_type='application/json',
max_result_window=10000,
search_factory_imp='rero_ils.query:and_search_factory',
search_factory_imp='rero_ils.query:search_factory',
read_permission_factory_imp=allow_all,
list_permission_factory_imp=allow_all,
create_permission_factory_imp=deny_all,
Expand Down Expand Up @@ -812,8 +813,8 @@ def _(x):
# Elasticsearch fields boosting by index
RERO_ILS_QUERY_BOOSTING = {
'documents': {
'title.*': 2,
'titlesProper.*': 2,
'title.*': 3,
'titlesProper.*': 3,
'authors.name': 2,
'authors.name_*': 2,
'publicationYearText': 2,
Expand Down Expand Up @@ -932,6 +933,7 @@ def _(x):

# Misc
INDEXER_REPLACE_REFS = True
INDEXER_RECORD_TO_INDEX = 'rero_ils.modules.indexer_utils.record_to_index'

SEARCH_UI_SEARCH_API = '/api/documents/'

Expand Down
9 changes: 8 additions & 1 deletion rero_ils/modules/documents/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ class Document(IlsRecord):
fetcher = document_id_fetcher
provider = DocumentProvider

@property
def harvested(self):
"""Is this record harvested from an external service."""
return bool(self.get('identifiers', {}).get('harvestedID'))

@property
def can_edit(self):
"""Return a boolean for can_edit resource."""
# TODO: Make this condition on data
return 'ebook' != self.get('type')
return not self.harvested

def get_number_of_items(self):
"""Get number of items for document."""
Expand Down Expand Up @@ -106,4 +111,6 @@ def reasons_not_to_delete(self):
links = self.get_links_to_me()
if links:
cannot_delete['links'] = links
if self.harvested:
cannot_delete['others'] = dict(harvested=True)
return cannot_delete
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Schema for ebooks document",
"title": "Schema for document",
"type": "object",
"required": [
"$schema",
"pid",
"type",
"title"
"title",
"languages"
],
"additionalProperties": false,
"properties": {
"$schema": {
"title": "Schema",
"description": "Schema to validate document against.",
"type": "string",
"minLength": 7
"minLength": 7,
"default": "https://ils.rero.ch/schema/documents/document-minimal-v0.0.1.json"
},
"pid": {
"title": "Document ID",
Expand Down Expand Up @@ -76,6 +78,7 @@
"title": "Language",
"description": "Required. Language of the resource, primary or not.",
"type": "string",
"default": "fre",
"validationMessage": "Required. Language of the resource, primary or not.",
"enum": [
"fre",
Expand All @@ -89,8 +92,7 @@
"heb",
"jpn",
"por",
"rus",
"und"
"rus"
]
}
}
Expand All @@ -107,37 +109,29 @@
"validationMessage": "Should be in the ISO 639 format, with 3 characters, ie <code>eng</code> for English."
}
},
"electronic_location": {
"title": "Electronic Location",
"description": "Information needed to locate and access an electronic resource.",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": [
"uri"
],
"uri": {
"title": "Uniform Resource Identifier",
"description": "Uniform Resource Identifier (URI), which provides standard syntax for locating an object using existing Internet protocols.",
"type": "string",
"format": "uri"
}
}
},
"authors": {
"title": "Authors",
"description": "Author(s) of the resource. Can be either persons or organisations.",
"type": "array",
"minItems": 1,
"minItems": 0,
"items": {
"type": "object",
"required": [
"name",
"type"
],
"additionalProperties": false,
"properties": {
"$ref": {
"title": "MEF person ref",
"type": "string",
"pattern": "^https://mef.rero.ch/api/mef/.*?$"
},
"pid": {
"title": "pid",
"description": "Corresponding pid of the MEF record.",
"type": "string",
"minLength": 1
},
"name": {
"title": "Name",
"description": "Person's or organisation's name.",
Expand Down Expand Up @@ -311,12 +305,12 @@
"pattern": "^97[8|9][0-9]{10}$",
"validationMessage": "Should be a valid ISBN-13 without dashes."
},
"oai": {
"title": "OAI",
"harvestedID": {
"title": "Identifier in the harvested source.",
"description": "OAI identifiers of the harvested source.",
"type": "string",
"pattern": "^oai:.*",
"validationMessage": "Should be a valid ISBN-13 without dashes."
"pattern": "^[a-z]+:.*",
"validationMessage": "Should start with a chars: prefix i.e. cantook:."
}
}
},
Expand All @@ -330,16 +324,29 @@
"minLength": 1
}
},
"available": {
"title": "Document availability",
"type": "boolean",
"default": false
},
"cover_art": {
"title": "Cover art",
"description": "Vendor cover art URL.",
"type": "string",
"format": "uri"
},
"electronic_location": {
"title": "Electronic Location",
"description": "Information needed to locate and access an electronic resource.",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": [
"uri"
],
"uri": {
"title": "Uniform Resource Identifier",
"description": "Uniform Resource Identifier (URI), which provides standard syntax for locating an object using existing Internet protocols.",
"type": "string",
"format": "uri"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@
"type": "string",
"pattern": "^97[8|9][0-9]{10}$",
"validationMessage": "Should be a valid ISBN-13 without dashes."
},
"harvestedID": {
"title": "Identifier in the harvested source.",
"description": "OAI identifiers of the harvested source.",
"type": "string",
"pattern": "^[a-z]+:.*",
"validationMessage": "Should start with a chars: prefix i.e. cantook:."
}
}
},
Expand All @@ -316,6 +323,30 @@
"type": "string",
"minLength": 1
}
},
"cover_art": {
"title": "Cover art",
"description": "Vendor cover art URL.",
"type": "string",
"format": "uri"
},
"electronic_location": {
"title": "Electronic Location",
"description": "Information needed to locate and access an electronic resource.",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": [
"uri"
],
"uri": {
"title": "Uniform Resource Identifier",
"description": "Uniform Resource Identifier (URI), which provides standard syntax for locating an object using existing Internet protocols.",
"type": "string",
"format": "uri"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
},
"mappings": {
"document-v0.0.1": {
"document": {
"date_detection": false,
"numeric_detection": false,
"properties": {
Expand Down
Loading