[damned-lies] Fixes #92 - Repaired redirection after login
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fixes #92 - Repaired redirection after login
- Date: Sat, 11 Aug 2018 12:50:37 +0000 (UTC)
commit d1d6e1afb43d34cea8ed2a34bebc06326381f57f
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Aug 11 14:43:54 2018 +0200
Fixes #92 - Repaired redirection after login
Regression in d44360a3b986a6316c2e538124496c1e54d42abb.
common/views.py | 7 +++++++
people/tests.py | 6 ++++++
2 files changed, 13 insertions(+)
---
diff --git a/common/views.py b/common/views.py
index 5e33f06a..00f2262d 100644
--- a/common/views.py
+++ b/common/views.py
@@ -44,6 +44,13 @@ def about(request):
class LoginView(AuthLoginView):
form_class = LoginForm
+ redirect_field_name = 'referer'
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ if not context['referer']:
+ context['referer'] = self.request.META.get('HTTP_REFERER', '')
+ return context
def form_valid(self, form):
response = super().form_valid(form)
diff --git a/people/tests.py b/people/tests.py
index 32b34967..6e15de5e 100644
--- a/people/tests.py
+++ b/people/tests.py
@@ -58,6 +58,12 @@ class PeopleTestCase(TestCase):
def test_login_message(self):
self.pn = self._create_person()
+ response = self.client.get(reverse('login'), HTTP_REFERER='http://foo/bar')
+ self.assertContains(
+ response,
+ '<input type="hidden" name="referer" value="http://foo/bar">',
+ html=True
+ )
response = self.client.post(
reverse('login'), data={'username': 'jn', 'password': 'password'}, follow=True
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]