Commit a58b193b authored by Oliver Falk's avatar Oliver Falk

Merge branch 'devel' into 'master'

Hotfix

See merge request !168
parents b74ab99e 060a664d
Pipeline #1968 passed with stages
in 8 minutes and 35 seconds
...@@ -143,9 +143,6 @@ if 'POSTGRESQL_DATABASE' in os.environ: ...@@ -143,9 +143,6 @@ if 'POSTGRESQL_DATABASE' in os.environ:
'HOST': 'postgresql', 'HOST': 'postgresql',
} }
if os.path.isfile(os.path.join(BASE_DIR, 'config_local.py')):
from config_local import * # noqa # flake8: noqa # NOQA # pragma: no cover
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
USE_X_FORWARDED_HOST = True USE_X_FORWARDED_HOST = True
...@@ -189,7 +186,7 @@ CACHES = { ...@@ -189,7 +186,7 @@ CACHES = {
'filesystem': { 'filesystem': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/var/tmp/ivatar_cache', 'LOCATION': '/var/tmp/ivatar_cache',
'TIMEOUT': 300, 'TIMEOUT': 900, # 15 minutes
} }
} }
...@@ -197,4 +194,8 @@ CACHES = { ...@@ -197,4 +194,8 @@ CACHES = {
# so the sites don't hit ivatar so much - it's what's set in the HTTP header # so the sites don't hit ivatar so much - it's what's set in the HTTP header
CACHE_IMAGES_MAX_AGE = 5 * 60 CACHE_IMAGES_MAX_AGE = 5 * 60
CACHE_RESPONSE = False CACHE_RESPONSE = True
# This MUST BE THE LAST!
if os.path.isfile(os.path.join(BASE_DIR, 'config_local.py')):
from config_local import * # noqa # flake8: noqa # NOQA # pragma: no cover
...@@ -322,7 +322,8 @@ class GravatarProxyView(View): ...@@ -322,7 +322,8 @@ class GravatarProxyView(View):
gravatar_test_url = 'https://secure.gravatar.com/avatar/' + kwargs['digest'] \ gravatar_test_url = 'https://secure.gravatar.com/avatar/' + kwargs['digest'] \
+ '?s=%i' % 50 + '?s=%i' % 50
if cache.get(gravatar_test_url) == 'default': if cache.get(gravatar_test_url) == 'default':
print("Cached Gravatar response: Default.") # DEBUG only
# print("Cached Gravatar response: Default.")
return redir_default(default) return redir_default(default)
try: try:
testdata = urlopen(gravatar_test_url, timeout=URL_TIMEOUT) testdata = urlopen(gravatar_test_url, timeout=URL_TIMEOUT)
...@@ -365,8 +366,7 @@ class GravatarProxyView(View): ...@@ -365,8 +366,7 @@ class GravatarProxyView(View):
data = BytesIO(gravatarimagedata.read()) data = BytesIO(gravatarimagedata.read())
img = Image.open(data) img = Image.open(data)
data.seek(0) data.seek(0)
response = CachingHttpResponse( response = HttpResponse(
uri,
data.read(), data.read(),
content_type='image/%s' % file_format(img.format)) content_type='image/%s' % file_format(img.format))
response['Cache-Control'] = 'max-age=%i' % CACHE_IMAGES_MAX_AGE response['Cache-Control'] = 'max-age=%i' % CACHE_IMAGES_MAX_AGE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment