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

@ -75,6 +75,13 @@ class SessionData(models.Model):
except:
self.location_sort = self.location = None
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):
if self.user:

View file

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

View file

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