diff --git a/pandora/user/models.py b/pandora/user/models.py index 8dfa7f4ef..6cce2dffe 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -69,12 +69,19 @@ class SessionData(models.Model): self.location = u'%s, %s' % (city, country) self.location_sort = u'%s, %s' % (country, city) else: - self.location_sort = self.location = country + self.location_sort = self.location = country else: self.location_sort = self.location = None 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: diff --git a/static/js/pandora/statisticsDialog.js b/static/js/pandora/statisticsDialog.js index 4125bf137..3ea248600 100644 --- a/static/js/pandora/statisticsDialog.js +++ b/static/js/pandora/statisticsDialog.js @@ -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) { diff --git a/static/js/pandora/usersDialog.js b/static/js/pandora/usersDialog.js index c49cb0eeb..4b40be6a4 100644 --- a/static/js/pandora/usersDialog.js +++ b/static/js/pandora/usersDialog.js @@ -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: '', tooltip: value