Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions deploy/webapp_settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@

SCHEDULED_ELECTION_DATES = ["2023-05-04", "2023-05-18"]

STORAGES = {
"default": {
"BACKEND": "ynr.storages.MediaStorage",
},
"staticfiles": {
"BACKEND": "ynr.storages.StaticStorage",
},
}


STATICFILES_STORAGE = "ynr.storages.StaticStorage"
DEFAULT_FILE_STORAGE = "ynr.storages.MediaStorage"
AWS_STORAGE_BUCKET_NAME = "static-candidates.democracyclub.org.uk"
AWS_S3_REGION_NAME = "eu-west-2"
STATICFILES_LOCATION = "static"
Expand Down
6 changes: 5 additions & 1 deletion deploy/webapp_settings/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@

# **** Settings that might be useful in production

STATICFILES_STORAGE = "pipeline.storage.PipelineCachedStorage"
STORAGES = {
"staticfiles": {
"BACKEND": "pipeline.storage.PipelineCachedStorage",
},
}
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
# RAVEN_CONFIG = {
Expand Down
10 changes: 8 additions & 2 deletions ynr/apps/candidates/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ def equal_call_args(args1, args2):


@override_settings(
STATICFILES_STORAGE="django.contrib.staticfiles.storage.StaticFilesStorage",
DEFAULT_FILE_STORAGE="ynr.storages.TestMediaStorage",
STORAGES={
"default": {
"BACKEND": "ynr.storages.TestMediaStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
},
MEDIA_ROOT=mkdtemp(),
)
class TmpMediaRootMixin(TestCase):
Expand Down
6 changes: 2 additions & 4 deletions ynr/apps/parties/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

"""
from candidates.tests.helpers import TmpMediaRootMixin
from django.conf import settings
from django.core.files.storage import DefaultStorage
from django.test import TestCase

Expand All @@ -25,13 +24,12 @@ def test_party_emblem(self):
self.assertEqual(party.emblems.count(), 3)
first_emblem = party.emblems.first()
self.assertEqual(
first_emblem.image.url,
f"{settings.MEDIA_ROOT}/emblems/PP0/{first_emblem.ec_emblem_id}_example.jpg",
first_emblem.image.url, "/media/emblems/PP0/1_example.jpg"
)

# Add a default image and assert it's the deafult on the party
PartyEmblemFactory(party=party, __sequence=99, default=True)
self.assertEqual(
party.default_emblem.image.url,
f"{settings.MEDIA_ROOT}/emblems/PP0/99_example.jpg",
"/media/emblems/PP0/99_example.jpg",
)
6 changes: 5 additions & 1 deletion ynr/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ def root(*path):

STATICFILES_LOCATION = "static"
MEDIAFILES_LOCATION = "media"
STATICFILES_STORAGE = "ynr.storages.StaticStorage"
STORAGES = {
"staticfiles": {
"BACKEND": "ynr.storages.StaticStorage",
},
}
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
Expand Down
6 changes: 5 additions & 1 deletion ynr/settings/local.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ ADMINS = [()]

# **** Settings that might be useful in production

# STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
# STORAGES = {
"staticfiles": {
"BACKEND": "pipeline.storage.PipelineCachedStorage",
},
},
# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'

Expand Down
6 changes: 5 additions & 1 deletion ynr/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ def __getitem__(self, item):

ALWAYS_ALLOW_RESULT_RECORDING = False

DEFAULT_FILE_STORAGE = "ynr.storages.TestMediaStorage"
STORAGES = {
"default": {
"BACKEND": "ynr.storages.TestMediaStorage",
},
}
MEDIA_ROOT = mkdtemp()