move fallback location test (email TLD) into the backend

This commit is contained in:
rolux 2012-03-27 07:29:01 +00:00
parent 9098e22b68
commit 8a1fd4afda
3 changed files with 13 additions and 14 deletions

View file

@ -69,12 +69,19 @@ class SessionData(models.Model):
self.location = u'%s, %s' % (city, country) self.location = u'%s, %s' % (city, country)
self.location_sort = u'%s, %s' % (country, city) self.location_sort = u'%s, %s' % (country, city)
else: else:
self.location_sort = self.location = country self.location_sort = self.location = country
else: else:
self.location_sort = self.location = None self.location_sort = self.location = None
except: except:
self.location_sort = self.location = None self.location_sort = self.location = None
pass pass
if self.location == None and self.user and self.user.email:
tld = self.user.email.split('.')[-1]
if tld in ['edu', 'gov', 'mil']:
tld = 'us'
country = ox.get_country_name(tld)
if country:
self.location_sort = self.location = country
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if self.user: if self.user:

View file

@ -93,10 +93,10 @@ pandora.ui.statisticsDialog = function() {
$tabPanel; $tabPanel;
Ox.getJSON('/static/json/deleteme.json', function(result) { //Ox.getJSON('/static/json/deleteme.json', function(result) {
/* ///*
pandora.api.findUsers({ pandora.api.findUsers({
keys: ['browser', 'email', 'firstseen', 'lastseen', 'level', 'location', 'system'], keys: ['browser', 'firstseen', 'lastseen', 'level', 'location', 'system'],
query: { query: {
conditions: [{key: 'level', value: 'robot', operator: '!='}], conditions: [{key: 'level', value: 'robot', operator: '!='}],
operator: '&' operator: '&'
@ -104,7 +104,7 @@ pandora.ui.statisticsDialog = function() {
range: [0, 1000000], range: [0, 1000000],
sort: [{key: 'username', operator: '+'}] sort: [{key: 'username', operator: '+'}]
}, function(result) { }, function(result) {
*/ //*/
var data = {}, var data = {},
flagCountry = {}, flagCountry = {},
@ -144,11 +144,6 @@ pandora.ui.statisticsDialog = function() {
data[mode].day[day][hour] = (data[mode].day[day][hour] || 0) + 1; data[mode].day[day][hour] = (data[mode].day[day][hour] || 0) + 1;
data[mode].hour[hour] = (data[mode].hour[hour] || 0) + 1; data[mode].hour[hour] = (data[mode].hour[hour] || 0) + 1;
}); });
if (!item.location) {
item.location = (Ox.getCountryByCode(
item.email.split('.').pop().replace(/(edu|gov|mil)/i, 'us')
) || {}).name || '';
}
if (item.location) { if (item.location) {
split = item.location.split(', ') split = item.location.split(', ')
if (split.length == 1) { if (split.length == 1) {

View file

@ -170,10 +170,7 @@ pandora.ui.usersDialog = function() {
width: 16 width: 16
}, },
{ {
format: function(value, data) { format: function(value) {
value = value || (Ox.getCountryByCode(
data.email.split('.').pop().replace(/(edu|gov|mil)/i, 'us')
) || {}).name || '';
return Ox.Element({ return Ox.Element({
element: '<img>', element: '<img>',
tooltip: value tooltip: value