Skip to content

Commit 3508c99

Browse files
authored
Convert custom_storages.py to a python module (#2289)
* Convert custom_storages.py to a python module * Do not use a mutable object as the default value of the function argument * Install production dependencies on GitHub action to running the tests * Avoid upgrading Django by defining versions to production deps Whitenoise > 6.0.0 and django-storages > 1.12.3 requires Django 3.2 or higher * Remove imports on custom_storages __init__ file to avoid error when execute the tests
1 parent 66af2ac commit 3508c99

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

custom_storages/__init__.py

Whitespace-only changes.

custom_storages.py renamed to custom_storages/storages.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ def get_comment_blocks(self, content):
2929
"""
3030
return [
3131
(match.start(), match.end())
32-
for match in re.finditer(r"\/\*.*?\*\/", content, flags=re.DOTALL)
32+
for match in re.finditer(r'\/\*.*?\*\/', content, flags=re.DOTALL)
3333
]
3434

35-
def url_converter(self, name, hashed_files, template=None, comment_blocks=[]):
35+
def url_converter(self, name, hashed_files, template=None, comment_blocks=None):
3636
"""
3737
Return the custom URL converter for the given file name.
3838
"""
39+
if comment_blocks is None:
40+
comment_blocks = []
41+
3942
if template is None:
4043
template = self.default_template
4144

prod-requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ gunicorn==19.9.0
33
raven==6.10.0
44

55
# Heroku
6-
Whitenoise
7-
django-storages
8-
boto3
6+
Whitenoise==6.0.0 # 6.0.0 is latest version that supports Django 2.2
7+
django-storages==1.12.3 # 1.12.3 is latest version that supports Django 2.2
8+
boto3==1.26.165

pydotorg/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
MEDIA_ROOT = os.path.join(BASE, 'media')
4747
MEDIA_URL = '/media/'
48+
MEDIAFILES_LOCATION = 'media'
4849

4950
# Absolute path to the directory static files should be collected to.
5051
# Don't put anything in this directory yourself; store your static files

pydotorg/settings/heroku.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
] + MIDDLEWARE
4242

4343
MEDIAFILES_LOCATION = 'media'
44-
DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'
45-
STATICFILES_STORAGE = 'custom_storages.PipelineManifestStorage'
44+
DEFAULT_FILE_STORAGE = 'custom_storages.storages.MediaStorage'
45+
STATICFILES_STORAGE = 'custom_storages.storages.PipelineManifestStorage'
4646

4747
EMAIL_HOST = config('EMAIL_HOST')
4848
EMAIL_HOST_USER = config('EMAIL_HOST_USER')

0 commit comments

Comments
 (0)