Merge branch 'devel' into 'master'

Fix redir check

See merge request oliver/ivatar!163
This commit is contained in:
Oliver Falk
2020-02-24 16:01:13 +01:00
4 changed files with 49 additions and 4 deletions

View File

@@ -180,7 +180,7 @@ class Photo(BaseAccountModel):
# Testing? Ideas anyone? # Testing? Ideas anyone?
except Exception as exc: # pylint: disable=broad-except except Exception as exc: # pylint: disable=broad-except
# For debugging only # For debugging only
print('Exception caught: %s' % exc) print('Exception caught in Photo.save(): %s' % exc)
return False return False
self.format = file_format(img.format) self.format = file_format(img.format)
if not self.format: if not self.format:

View File

@@ -1225,10 +1225,12 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
) )
) )
url = '%s?%s' % (urlobj.path, urlobj.query) url = '%s?%s' % (urlobj.path, urlobj.query)
response = self.client.get(url, follow=True) response = self.client.get(url, follow=False)
self.assertRedirects( self.assertRedirects(
response=response, response=response,
expected_url='/gravatarproxy/1b1d0b654430c012e47e350db07c83c5?s=80&default=mm', expected_url='/gravatarproxy/1b1d0b654430c012e47e350db07c83c5?s=80&default=mm',
status_code=302,
target_status_code=200,
msg_prefix='Why does this not redirect to the gravatarproxy and defaulting to mm?') msg_prefix='Why does this not redirect to the gravatarproxy and defaulting to mm?')
# Eventually one should check if the data is the same # Eventually one should check if the data is the same

View File

@@ -13,7 +13,6 @@ urlpatterns = [ # pylint: disable=invalid-name
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('i18n/', include('django.conf.urls.i18n')), path('i18n/', include('django.conf.urls.i18n')),
url('openid/', include('django_openid_auth.urls')), url('openid/', include('django_openid_auth.urls')),
url('accounts/', include('ivatar.ivataraccount.urls')),
url('tools/', include('ivatar.tools.urls')), url('tools/', include('ivatar.tools.urls')),
url( url(
r'avatar/(?P<digest>\w{64})', r'avatar/(?P<digest>\w{64})',
@@ -36,7 +35,21 @@ urlpatterns = [ # pylint: disable=invalid-name
url('privacy/', TemplateView.as_view(template_name='privacy.html'), name='privacy'), url('privacy/', TemplateView.as_view(template_name='privacy.html'), name='privacy'),
url('contact/', TemplateView.as_view(template_name='contact.html'), name='contact'), url('contact/', TemplateView.as_view(template_name='contact.html'), name='contact'),
path('talk_to_us/', RedirectView.as_view(url='/contact'), name='talk_to_us'), path('talk_to_us/', RedirectView.as_view(url='/contact'), name='talk_to_us'),
url('', TemplateView.as_view(template_name='home.html'), name='home'),
] ]
MAINTENANCE = False
try:
if settings.MAINTENANCE:
MAINTENANCE = True
except:
pass
if MAINTENANCE:
urlpatterns.append(url('', TemplateView.as_view(template_name='maintenance.html'), name='home'))
urlpatterns.insert(3, url('accounts/', RedirectView.as_view(url='/')))
else:
urlpatterns.append(url('', TemplateView.as_view(template_name='home.html'), name='home'))
urlpatterns.insert(3, url('accounts/', include('ivatar.ivataraccount.urls')))
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

View File

@@ -0,0 +1,30 @@
{% extends 'base_home.html' %}
{% load i18n %}
{% load static %}
{% block title %}{% trans 'federated avatar hosting service' %}{% endblock %}
{% block content %}
<div class="hero">
<div class="container">
<header>
<h1 id='app'>{{ site_name }}</h1>
<h2>{% trans 'freeing the web one face at a time' %}</h2>
</header>
</div>
</div>
<section class="content">
<div class="container">
<div class="text-center">
<h2 style="text-transform: capitalize;font-size: 35px;">{% trans 'Maintenance mode' %}</h2>
Libravatar is currently in maintenance mode.<br/>
Avatars are still served, but all write operations may result
in loss of these changes.
</p>
<hr/>
</div>
</div>
</section>
{% endblock %}