forked from CenterForOpenScience/osf.io
-
Notifications
You must be signed in to change notification settings - Fork 0
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 CenterForOpenScience#10515 from cslzchen/feature/e…
…ng-5020-record-crud-api [ENG-5203] Add metadata records relationships to nodes, registrations and files
- Loading branch information
Showing
13 changed files
with
200 additions
and
42 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
|
||
from osf.models import BaseFileNode, CedarMetadataRecord, Node, Registration | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_guids_related_view(obj): | ||
assert isinstance(obj, CedarMetadataRecord), 'object must be a CedarMetadataRecord' | ||
referent = obj.guid.referent | ||
if isinstance(referent, Node): | ||
return 'nodes:node-detail' | ||
elif isinstance(referent, Registration): | ||
return 'registrations:registration-detail' | ||
elif isinstance(referent, BaseFileNode): | ||
return 'files:file-detail' | ||
else: | ||
raise NotImplementedError() | ||
|
||
|
||
def get_guids_related_view_kwargs(obj): | ||
assert isinstance(obj, CedarMetadataRecord), 'object must be a CedarMetadataRecord' | ||
referent = obj.guid.referent | ||
if isinstance(referent, (Node, Registration)): | ||
return {'node_id': '<guid._id>'} | ||
elif isinstance(referent, BaseFileNode): | ||
return {'file_id': '<guid._id>'} | ||
else: | ||
raise NotImplementedError() |
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
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
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
Oops, something went wrong.