From 6e876c2b4d06b091af73cffbe7633e84026e8cd0 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 3 Feb 2012 14:44:11 +0000 Subject: [PATCH] geonames are not unique --- pandora/place/models.py | 4 ++-- pandora/place/views.py | 4 ++++ static/js/pandora/infoView.js | 9 +++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pandora/place/models.py b/pandora/place/models.py index bb9da4232..26a1a8395 100644 --- a/pandora/place/models.py +++ b/pandora/place/models.py @@ -32,8 +32,8 @@ class Place(models.Model): name_sort = models.CharField(max_length=200) name_find = models.TextField(default='', editable=False) - geoname = models.CharField(max_length=1024, unique=True, null=True) - geoname_sort = models.CharField(max_length=1024, unique=True, null=True) + geoname = models.CharField(max_length=1024, null=True) + geoname_sort = models.CharField(max_length=1024, null=True) countryCode = models.CharField(max_length=16, default='') wikipediaId = models.CharField(max_length=1000, blank=True) diff --git a/pandora/place/views.py b/pandora/place/views.py index 77942a640..db9547290 100644 --- a/pandora/place/views.py +++ b/pandora/place/views.py @@ -46,11 +46,13 @@ def addPlace(request): name_find__icontains=u'|%s|'%name).count() != 0: exists = True existing_names.append(name) + ''' if 'geoname' in data: if models.Place.objects.filter(defined=True, geoname=data['geoname']).count() > 0: exists = True existing_geoname = data['geoname'] + ''' if not exists: models.Place.objects.filter(defined=False, name__in=names).delete() place = models.Place() @@ -103,11 +105,13 @@ def editPlace(request): name_find__icontains=u'|%s|'%name).exclude(id=place.id).count() != 0: conflict = True conflict_names.append(name) + ''' if 'geoname' in data: if models.Place.objects.filter(defined=True, geoname=data['geoname']).exclude(id=place.id).count() != 0: conflict = True conflict_geoname = data['geoname'] + ''' if not conflict: models.Place.objects.filter(defined=False, name__in=names+alternative_names).delete() for key in data: diff --git a/static/js/pandora/infoView.js b/static/js/pandora/infoView.js index 9b3f83b6d..7b6856cfb 100644 --- a/static/js/pandora/infoView.js +++ b/static/js/pandora/infoView.js @@ -241,10 +241,11 @@ pandora.ui.infoView = function(data) { ['country', 'year', 'language', 'runtime'].forEach(function(key) { if (data[key]) { html.push( - formatKey(key) - + (key == 'runtime' - ? Math.round(data[key] / 60) + ' min' - : formatValue(data[key], key)) + formatKey(key) + ( + key != 'runtime' ? formatValue(data[key], key) + : data[key] < 60 ? Math.round(data[key]) + ' sec' + : Math.round(data[key] / 60) + ' min' + ) ) } });