Skip to content

Commit

Permalink
add get_content() method to svg files
Browse files Browse the repository at this point in the history
  • Loading branch information
pix666 committed Mar 14, 2024
1 parent dce312d commit 9948108
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [0.18.7](https://github.com/dldevinc/paper-streamfield/tree/v0.18.7) - 2024-03-14

### Features

- Added new method `get_content()` to `UploadedSVGFile`.

## [0.18.6](https://github.com/dldevinc/paper-streamfield/tree/v0.18.6) - 2024-03-04

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion paper_uploads/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.18.6"
__version__ = "0.18.7"
default_app_config = "paper_uploads.apps.Config"
6 changes: 6 additions & 0 deletions paper_uploads/models/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def as_dict(self) -> Dict[str, Any]:
),
}

def get_content(self) -> str:
fp = self.open("r")
content = fp.read()
self.close()
return content.strip()

@classmethod
def get_configuration(cls) -> Dict[str, Any]:
return {
Expand Down
4 changes: 4 additions & 0 deletions tests/tests/models/test_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def test_as_dict(self, storage):
ignore={"id"}
)

def test_get_content(self, storage):
content = storage.resource.get_content()
assert "<svg" in content


class TestUploadedFileAttach(BaseTestFileFieldResourceAttach):
resource_class = UploadedSVGFile
Expand Down

0 comments on commit 9948108

Please sign in to comment.