Révision 9f8bbe95
Ajouté par Thomas Noël il y a plus de 9 ans
usr/local/univnautes/sp/sp/views.py | ||
---|---|---|
21 | 21 |
from django.contrib.auth.decorators import login_required |
22 | 22 |
import urllib2 |
23 | 23 |
from django.http import HttpResponse |
24 |
from django.shortcuts import redirect |
|
25 |
import subprocess |
|
26 |
|
|
24 | 27 |
|
25 | 28 |
class Homepage(TemplateView): |
26 | 29 |
'''Homepage View, displays a welcome message''' |
27 | 30 |
template_name = 'homepage.html' |
28 |
|
|
29 | 31 |
homepage = login_required(Homepage.as_view()) |
30 | 32 |
|
33 |
|
|
31 | 34 |
def proxymap(request, z, x, y): |
32 | 35 |
url = settings.PROXYMAP_URL % { 'z': int(z), 'x': int(x), 'y': int(y) } |
33 | 36 |
downstream_request = urllib2.Request(url) |
34 | 37 |
page = urllib2.urlopen(downstream_request) |
35 | 38 |
return HttpResponse(page, page.info().getheader('Content-Type')) |
36 | 39 |
|
40 |
def logout(request): |
|
41 |
# 1. disconnect from the captive portal |
|
42 |
cmd = [ c % { |
|
43 |
'cpzone': request.META.get('HTTP_X_PFSENSE_CPZONE') or '', |
|
44 |
'ip': request.META['REMOTE_ADDR'], |
|
45 |
} for c in settings.UNIVNAUTES_CP_DISCONNECT_CMD ] |
|
46 |
p = subprocess.call(cmd) |
|
47 |
# 2. disconnect from django |
|
48 |
return redirect('django_logout_then_login') |
|
49 |
|
Formats disponibles : Unified diff
logout view: disconnect from cp