Skip to content
Snippets Groups Projects
Commit e468f8fb authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Do not use PrivateMediaStorage when DEBUG is True.

parent f67bded6
No related branches found
No related tags found
No related merge requests found
...@@ -283,7 +283,10 @@ class ApplicationSubmission( ...@@ -283,7 +283,10 @@ class ApplicationSubmission(
editable=False, editable=False,
) )
private_storage = PrivateMediaStorage() if settings.DEBUG:
submission_storage = DefaultStorage()
else:
submission_storage = PrivateMediaStorage()
# Meta: used for migration purposes only # Meta: used for migration purposes only
drupal_id = models.IntegerField(null=True, blank=True, editable=False) drupal_id = models.IntegerField(null=True, blank=True, editable=False)
...@@ -356,7 +359,7 @@ class ApplicationSubmission( ...@@ -356,7 +359,7 @@ class ApplicationSubmission(
def save_path(self, file_name): def save_path(self, file_name):
file_path = os.path.join('submissions', 'user', str(self.user.id), file_name) file_path = os.path.join('submissions', 'user', str(self.user.id), file_name)
return self.private_storage.generate_filename(file_path) return self.submission_storage.generate_filename(file_path)
def handle_file(self, file): def handle_file(self, file):
# File is potentially optional # File is potentially optional
...@@ -367,11 +370,11 @@ class ApplicationSubmission( ...@@ -367,11 +370,11 @@ class ApplicationSubmission(
# file is not changed, it is still the dictionary # file is not changed, it is still the dictionary
return file return file
saved_name = self.private_storage.save(filename, file) saved_name = self.submission_storage.save(filename, file)
return { return {
'name': file.name, 'name': file.name,
'path': saved_name, 'path': saved_name,
'url': self.private_storage.url(saved_name), 'url': self.submission_storage.url(saved_name),
} }
def handle_files(self, files): def handle_files(self, files):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment