From: Guillaume Pellerin Date: Thu, 11 Jul 2013 21:06:21 +0000 (+0200) Subject: HOST context goes to telecaster-client X-Git-Tag: 1.3-TC~40 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=204ad2a1f2e47b372f5b1e12e1e3237af8b10197;p=teleforma.git HOST context goes to telecaster-client --- diff --git a/teleforma/context_processors.py b/teleforma/context_processors.py index 8d044d34..94fadbbb 100644 --- a/teleforma/context_processors.py +++ b/teleforma/context_processors.py @@ -35,14 +35,6 @@ from teleforma.views.core import * -from django.conf import settings -import socket -import fcntl -import struct - -interfaces = ['eth0', 'eth1', 'eth2', 'eth0-eth2', 'eth3', 'eth4', - 'wlan0', 'wlan1', 'wlan2', 'wlan3', 'wlan4'] - def periods(request): """return the periods assigned to the user """ @@ -53,47 +45,3 @@ def periods(request): return {'periods': None} else: return {'periods': get_periods(user)} - - - -def get_ip_address(ifname): - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - ip = socket.inet_ntoa(fcntl.ioctl( - s.fileno(), - 0x8915, # SIOCGIFADDR - struct.pack('256s', ifname[:15]) - )[20:24]) - return ip - -def get_local_host(): - ip = '' - for interface in interfaces: - try: - ip = get_ip_address(interface) - if ip: - local_ip = ip - break - except: - local_ip = '127.0.0.1' - return local_ip - - -def get_http_host(request): - host = request.META['REMOTE_ADDR'] - if ':' in host: - host = host.split(':')[0] - return host - - -def host(request): - request_host = get_http_host(request) - local_host = get_local_host() - - if request_host.split('.')[0] == local_host.split('.')[0] or \ - request_host == '127.0.0.1' or request_host == 'localhost': - # LAN access - ip = local_host - else: - ip = settings.ROUTER_IP - - return {'HOST': ip }