Initial import

This commit is contained in:
2012-03-03 15:30:08 +00:00
commit 8042a33a8e
8 changed files with 94 additions and 0 deletions

10
eveigb/__init__.py Normal file
View File

@@ -0,0 +1,10 @@
VERSION = (0, 1)
# Dynamically calculate the version based on VERSION tuple
if len(VERSION)>2 and VERSION[2] is not None:
str_version = "%d.%d_%s" % VERSION[:3]
else:
str_version = "%d.%d" % VERSION[:2]
__version__ = str_version
VERSION = (0, 1)

View File

@@ -0,0 +1,6 @@
def igb(request):
return {
'is_igb': request.is_igb,
'is_igb_trusted': request.is_igb_trusted,
}

42
eveigb/middleware.py Normal file
View File

@@ -0,0 +1,42 @@
class IGBMiddleware(object):
"""
Middleware to detect the EVE IGB
"""
def process_request(self, request):
request.is_igb = False
request.is_igb_trusted = False
header_map = [
('HTTP_EVE_SERVERIP', 'eve_server_ip'),
('HTTP_EVE_CHARNAME', 'eve_charname'),
('HTTP_EVE_CHARID', 'eve_charid'),
('HTTP_EVE_CORPNAME', 'eve_corpname'),
('HTTP_EVE_CORPID', 'eve_corpid'),
('HTTP_EVE_ALLIANCENAME', 'eve_alliancename'),
('HTTP_EVE_ALLIANCEID', 'eve_allianceid'),
('HTTP_EVE_REGIONNAME', 'eve_regionid'),
('HTTP_EVE_CONSTELLATIONNAME', 'eve_constellationname'),
('HTTP_EVE_SOLARSYSTEMNAME', 'eve_systemname'),
('HTTP_EVE_STATIONNAME,' 'eve_stationname'),
('HTTP_EVE_STATIONID,' 'eve_stationid'),
('HTTP_EVE_CORPROLE,' 'eve_corprole'),
]
if 'EVE-IGB' in request.META.get('HTTP_USER_AGENT', ''):
request.is_igb = True
if request.META.get('HTTP_EVE_TRUSTED', 'No') == 'Yes':
request.is_igb_trusted = True
for header, map in header_map:
if request.META.get(header, None):
setattr(request, map, request.META.get(header, None))
def igb(request):
return {
'is_igb': request.is_igb,
'is_igb_trusted': request.is_igb_trusted,
}

View File

View File

@@ -0,0 +1,3 @@
from django import template
register = template.Library()

16
eveigb/tests.py Normal file
View File

@@ -0,0 +1,16 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)