New logout function (basic auth, not for IE)
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Tue, 17 Apr 2012 16:03:38 +0000 (16:03 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Tue, 17 Apr 2012 16:03:38 +0000 (16:03 +0000)
bin/common.py
bin/djais/context.py [new file with mode: 0644]
bin/djais/settings.py
bin/djais/views.py
www_templates/base.html
www_templates/logout.html

index 10ee80b425e43000ff9c175dea70b61cc50bb1d3..c13e72ca5711a0ff245c2982fead094be7e935f4 100755 (executable)
@@ -1990,7 +1990,7 @@ def main():
         print >> sys.stderr, "No ship to process"
         sys.exit(1)
 
-    target_mmsi_iterator = []
+    target_mmsi_iterator = [] # strmmsi
     all_targets = False
     for arg in args:
         if arg == 'all':
diff --git a/bin/djais/context.py b/bin/djais/context.py
new file mode 100644 (file)
index 0000000..8f26702
--- /dev/null
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+"""
+This context processor just add a "ais_base_url" key that's allways available
+"""
+
+from ais.djais.settings import AIS_BASE_URL
+from django.utils.safestring import mark_safe
+from urlparse import urlsplit
+
+logout_url = 'https://logout@' + urlsplit('https://ais.greenpeace.fr/logout').netloc + '/logout'
+
+def logout(request):
+    if 'MSIE' not in request.META.get('HTTP_USER_AGENT', ''):
+        return {'logout': mark_safe('☮ <a href="' + logout_url + '"> logout</a>') }
+    else:
+        return {}
index d90e8d4e423bab3a1389d5297c428215b6c7ac1b..5f94619467a1b5fd7d7b8e7ea402c5b3101cacb0 100644 (file)
@@ -92,7 +92,9 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     "django.core.context_processors.media",
     "django.core.context_processors.request", # Added by Nirgal
     "django.contrib.messages.context_processors.messages",
+    "ais.djais.context.logout", 
 )
 
 AIS_BASE_URL='https://ais.nirgal.com'
 NOTIFICATION_EMAIL='Job runner <contact_ais@nirgal.com>'
+
index 59716d1fa233feefe4d5fd8fe6209ec84a27085f..f68e9a3fdfa61c00a7ce1ce531fd34258a18b29b 100644 (file)
@@ -1107,10 +1107,8 @@ def user_delete(request, login):
 
 
 def logout(request):
-    # TODO
-    return HttpResponse('Not implemented')
-    #response = render_to_response('logout.html', {}, RequestContext(request))
-    #return response
+    response = render_to_response('logout.html', {}, RequestContext(request))
+    return response
 
 periods = ({
     'name_tiny': '2h',
index 9032e8e92c0a8783306ae7f9c12323178d1fd3e9..d4d8fde15793f454232458ad249e8a9e12b73686 100644 (file)
 
 <div id=header>
     <span id=bannertitle>AIS ship monitoring</span>
-    <span id=bannermenu>Welcome <a href='/user/{{user.login}}/'>{{ user.name }}</a> ☮ <a href='/user/{{user.login}}/change_password'>change password</a></span>
+    {% if user.login %}
+    <span id=bannermenu>
+        Welcome <a href='/user/{{user.login}}/'>{{ user.name }}</a>
+        ☮ <a href='/user/{{user.login}}/change_password'>change password</a>
+        {{ logout }}
+    </span>
+    {% endif %}
     <br class=clearall>
+    {% if user.login %}
     <div id=tabs>
         <a href='/'{% block tab_active_news %}{% endblock %} title="Home page">news</a>
         <a href='/vessel/'{% block tab_active_vessel %}{% endblock %} title="Look for some specific ships">vessels</a>
@@ -22,6 +29,7 @@
         {% endif %}
         <a href='/source/'{% block tab_active_source %}{% endblock %} title="Real time statistics">sources</a>
     </div>
+    {% endif %}
 </div>
 <div id=main>
     {% block breadcrumbs %}
index 464f158871fee6cebf9ec2676ae3da3a45f85346..0cdd044dc8692ffbb98fccf0854950c487383eaf 100644 (file)
@@ -1,5 +1,16 @@
 {% extends "base.html" %}
 
+{% block breadcrumbs %}
+{% endblock %}
+
+{% block title %}
+Logout
+{% endblock %}
+
 {% block content %}
-Have a nice day!
+<br>
+<br>
+<br>
+<br>
+<div style="text-align:center;">Have a nice day!</div>
 {% endblock %}