-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from oarepo/draftlisting&testbuild
Draftlisting&testbuild
- Loading branch information
Showing
48 changed files
with
87 additions
and
1,062 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from invenio_records.dictutils import dict_set | ||
from invenio_records.systemfields import SystemField | ||
from sqlalchemy.orm.exc import NoResultFound | ||
|
||
from oarepo_runtime.cf import CustomFieldsMixin | ||
|
||
|
||
# taken from https://github.com/inveniosoftware/invenio-rdm-records/blob/master/invenio_rdm_records/records/systemfields/has_draftcheck.py | ||
class HasDraftCheckField(CustomFieldsMixin, SystemField): | ||
"""PID status field which checks against an expected status.""" | ||
|
||
def __init__(self, draft_cls=None, key=None, **kwargs): | ||
"""Initialize the PIDField. | ||
It stores the `record.has_draft` value in the secondary storage | ||
system's record or defaults to `False` if the `draft_cls` is not passed | ||
e.g Draft records. | ||
:param key: Attribute name of the HasDraftCheckField. | ||
:param draft_cls: The draft class to use for querying. | ||
""" | ||
super().__init__(key=key, **kwargs) | ||
self.draft_cls = draft_cls | ||
|
||
# | ||
# Data descriptor methods (i.e. attribute access) | ||
# | ||
def __get__(self, record, owner=None): | ||
if record is None: | ||
return self # returns the field itself. | ||
|
||
# If not draft_cls is passed return False | ||
if self.draft_cls is None: | ||
return False | ||
|
||
try: | ||
self.draft_cls.get_record(record.id) | ||
return True | ||
except NoResultFound: | ||
return False | ||
|
||
def pre_dump(self, record, data, **kwargs): | ||
dict_set(data, self.key, record.has_draft) | ||
""" | ||
def post_load(self, record, data, **kwargs): | ||
record.pop(self.key, None) | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
set -e | ||
pip install -e '.[tests]' | ||
pip install -e 'tests/records2' | ||
pip uninstall -y uritemplate | ||
pip install uritemplate | ||
export PYTHONPATH=. | ||
|
||
MODEL="records2" | ||
VENV=".model_venv" | ||
|
||
if test -d ./tests/$MODEL; then | ||
rm -rf ./tests/$MODEL | ||
fi | ||
|
||
if test -d ./$VENV; then | ||
rm -rf ./$VENV | ||
fi | ||
|
||
oarepo-compile-model ./tests/$MODEL.yaml --output-directory ./tests/$MODEL -vvv | ||
python3 -m venv $VENV | ||
. $VENV/bin/activate | ||
pip install -U setuptools pip wheel | ||
pip install "./tests/$MODEL[tests]" | ||
rm -rf ./tests/$MODEL/tests | ||
pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
model: | ||
record: | ||
use: invenio | ||
schema-server: local:// | ||
properties: | ||
metadata: | ||
properties: | ||
title: keyword | ||
module: | ||
qualified: records2 | ||
permissions: | ||
presets: [ 'everyone' ] | ||
|
Oops, something went wrong.