[Python-modules-commits] [django-session-security] 02/16: Encode logout response to JSON (#69)

Jean-Michel Vourgère nirgal at moszumanska.debian.org
Tue Sep 13 17:04:15 UTC 2016


This is an automated email from the git hooks/post-receive script.

nirgal pushed a commit to branch debian/sid
in repository django-session-security.

commit 3e184627b87b2841b766bd26f3c49426ff894a66
Author: Andrew Udvare <Tatsh at users.noreply.github.com>
Date:   Wed Aug 10 05:32:45 2016 -0700

    Encode logout response to JSON (#69)
    
    * Encode logout response to JSON
    
    Send correct Content-Type header
    
    * README: update Django version requirement
---
 README.rst                           | 2 +-
 session_security/tests/test_views.py | 4 ++--
 session_security/views.py            | 6 ++++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/README.rst b/README.rst
index 96f641d..94b38b0 100644
--- a/README.rst
+++ b/README.rst
@@ -58,7 +58,7 @@ Requirements
 
 - Python 2.7 or 3
 - jQuery 1.7+
-- Django 1.4+
+- Django 1.7+
 - django.contrib.staticfiles or django-staticfiles (included in Pinax) or
   you're on your own
 
diff --git a/session_security/tests/test_views.py b/session_security/tests/test_views.py
index c451551..e3aed07 100644
--- a/session_security/tests/test_views.py
+++ b/session_security/tests/test_views.py
@@ -26,13 +26,13 @@ class ViewsTestCase(test.TestCase):
         self.client.logout()
         self.client.get('/admin/')
         response = self.client.get('/session_security/ping/?idleFor=1')
-        self.assertEqual(response.content, six.b('logout'))
+        self.assertEqual(response.content, six.b('"logout"'))
 
     ping_provider = lambda x=None: (
         (1, 4, '1'),
         (3, 2, '2'),
         (5, 5, '5'),
-        (12, 14, 'logout', False),
+        (12, 14, '"logout"', False),
     )
 
     @data_provider(ping_provider)
diff --git a/session_security/views.py b/session_security/views.py
index fb2e9e3..f89831f 100644
--- a/session_security/views.py
+++ b/session_security/views.py
@@ -21,8 +21,10 @@ class PingView(generic.View):
     def get(self, request, *args, **kwargs):
         if '_session_security' not in request.session:
             # It probably has expired already
-            return http.HttpResponse('logout')
+            return http.HttpResponse('"logout"',
+                                     content_type='application/json')
 
         last_activity = get_last_activity(request.session)
         inactive_for = (datetime.now() - last_activity).seconds
-        return http.HttpResponse(inactive_for)
+        return http.HttpResponse(inactive_for,
+                                 content_type='application/json')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-session-security.git



More information about the Python-modules-commits mailing list