Skip to content

Commit

Permalink
holdings: attach serials to non-serials documents
Browse files Browse the repository at this point in the history
* Allows to:
    * Attach holdings of serial type to any type of document.
    * Attach holdings of standard type to document of type journal.
    * Attach items of standard type to holdings of type serial.
* Closes #1612.

Co-Authored-by: Aly Badr <aly.badr@rero.ch>
  • Loading branch information
Aly Badr authored and rerowep committed Jan 27, 2021
1 parent fe2e70b commit f5095b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
9 changes: 3 additions & 6 deletions rero_ils/modules/holdings/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ def extended_validation(self, **kwargs):
frequency the next_expected_date should be given.
:return: False if
- document type is not journal and holding type is serial.
- document type is journal and holding type is not serial.
- document type is ebook and holding type is not electronic.
- document type is not ebook and holding type is electronic.
- holding type is serial and the next_expected_date
Expand All @@ -157,10 +155,9 @@ def extended_validation(self, **kwargs):
is_electronic = self.holdings_type == 'electronic'
is_issuance = \
document.get('issuance', {}).get('main_type') == 'rdami:1003'
if (is_serial and not is_issuance) \
or (document.harvested ^ is_electronic):
msg = _('Holding is not attached to the correct document type.'
' document: {pid}')
if (document.harvested ^ is_electronic):
msg = _('Electronic Holding is not attached to the correct \
document type. document: {pid}')
return _(msg.format(pid=document_pid))
# the enumeration and chronology optional fields are only allowed for
# serial holdings
Expand Down
2 changes: 0 additions & 2 deletions rero_ils/modules/items/api/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def extended_validation(self, **kwargs):
if not holding:
return _('Holding does not exist: {pid}.'.format(pid=holding_pid))
is_serial = holding.holdings_type == 'serial'
if is_serial and self.get('type') == 'standard':
return _('Standard item can not attached to a journal.')
issue = self.get('issue', {})
if issue and self.get('type') == 'standard':
return _('Standard item can not have a issue field.')
Expand Down
3 changes: 2 additions & 1 deletion tests/api/test_external_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def test_documents_import_bnf_ean(client):
res = client.get(url_for(
'api_imports.imports_search',
q='peter',
type='book',
document_type='docmaintype_book',
document_subtype='docsubtype_other_book',
format='rerojson'
))
assert res.status_code == 200
Expand Down

0 comments on commit f5095b9

Please sign in to comment.