Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Create test data * make permissions optional in schema * use optional type for permissions in xml_upload * update .gitignore * precise the use of username for CLI options * create testdata to test permissions * update xml_upload to handle optional permissions * Add bitstream resources to tests * use resource permissions for bitstream objects * remove duplicated code * remove duplicated code * update documentation * Remove unused file knora.py * use images to test permissions * allow permissions attribute for bitstreams * Refactor xml_upload.py * add bitstream to models * update documentation * Rename Knora instances * Update test data * Rename output labels * refactor bitstream * add bitstream to bazel * refactor resource, value and bitstream * cleanup code * update documentation * Allow separate permission for bitstream * add image related permissions to test data * fix failing test * refactor bitstream * Update documentation * update cli documentation * update url to permissions
- Loading branch information
irinaschubert
committed
Dec 7, 2021
1 parent
fd58ad4
commit 4dad0ce
Showing
21 changed files
with
659 additions
and
2,395 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ venv.bak/ | |
# created files | ||
lists.json | ||
out.json | ||
id2iri_* | ||
|
||
# bazel | ||
/bazel-* | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from typing import Dict, Optional, Any | ||
|
||
from pystrict import strict | ||
|
||
from .helpers import Actions | ||
from .permission import Permissions | ||
|
||
|
||
@strict | ||
class Bitstream: | ||
""" | ||
Represents a bitstream object (file) which is attached to a resource | ||
""" | ||
_value: str | ||
_permissions: Optional[Permissions] | ||
|
||
def __init__(self, | ||
value: str, | ||
permissions: Optional[Permissions] = None): | ||
self._value = value | ||
self._permissions = permissions | ||
|
||
@property | ||
def value(self) -> str: | ||
return self._value | ||
|
||
@property | ||
def permissions(self) -> Optional[Permissions]: | ||
return self._permissions | ||
|
||
def toJsonLdObj(self, action: Actions) -> Dict[str, Any]: | ||
tmp = {} | ||
if action == Actions.Create: | ||
tmp["knora-api:fileValueHasFilename"] = self._value | ||
if self._permissions: | ||
tmp["knora-api:hasPermissions"] = self.permissions.toJsonLdObj() | ||
return tmp |
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.