Skip to content

Commit 58f4623

Browse files
author
James (ODSC)
authored
Merge pull request #1 from OpenDataServices/2023-06-29
Model SuppliedDataFile has new method storage_name for use with Djang…
2 parents d5e9de1 + af97ab7 commit 58f4623

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
## Added
11+
12+
- Model SuppliedDataFile has new method storage_name for use with Django storage (like storage_dir on SuppliedData)
13+
1014
## [0.1.0] - 2023-06-16
1115

1216
First Release

libcoveweb2/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@ def upload_url(self):
138138
self.filename,
139139
)
140140

141+
def storage_name(self):
142+
"""For use with Django storage classes.
143+
Returns full name in storage
144+
Example use:
145+
default_storage.open(os.path.join(supplied_data_file.storage_name())
146+
"""
147+
return os.path.join(
148+
str(self.supplied_data.id),
149+
"supplied_data",
150+
str(self.id),
151+
self.filename,
152+
)
153+
141154
def does_exist_in_storage(self):
142155
return os.path.exists(self.upload_dir_and_filename())
143156

0 commit comments

Comments
 (0)