geonames are not unique

This commit is contained in:
j 2012-02-03 14:44:11 +00:00
parent 46996b0e54
commit 6e876c2b4d
3 changed files with 11 additions and 6 deletions

View file

@ -32,8 +32,8 @@ class Place(models.Model):
name_sort = models.CharField(max_length=200) name_sort = models.CharField(max_length=200)
name_find = models.TextField(default='', editable=False) name_find = models.TextField(default='', editable=False)
geoname = models.CharField(max_length=1024, unique=True, null=True) geoname = models.CharField(max_length=1024, null=True)
geoname_sort = models.CharField(max_length=1024, unique=True, null=True) geoname_sort = models.CharField(max_length=1024, null=True)
countryCode = models.CharField(max_length=16, default='') countryCode = models.CharField(max_length=16, default='')
wikipediaId = models.CharField(max_length=1000, blank=True) wikipediaId = models.CharField(max_length=1000, blank=True)

View file

@ -46,11 +46,13 @@ def addPlace(request):
name_find__icontains=u'|%s|'%name).count() != 0: name_find__icontains=u'|%s|'%name).count() != 0:
exists = True exists = True
existing_names.append(name) existing_names.append(name)
'''
if 'geoname' in data: if 'geoname' in data:
if models.Place.objects.filter(defined=True, if models.Place.objects.filter(defined=True,
geoname=data['geoname']).count() > 0: geoname=data['geoname']).count() > 0:
exists = True exists = True
existing_geoname = data['geoname'] existing_geoname = data['geoname']
'''
if not exists: if not exists:
models.Place.objects.filter(defined=False, name__in=names).delete() models.Place.objects.filter(defined=False, name__in=names).delete()
place = models.Place() place = models.Place()
@ -103,11 +105,13 @@ def editPlace(request):
name_find__icontains=u'|%s|'%name).exclude(id=place.id).count() != 0: name_find__icontains=u'|%s|'%name).exclude(id=place.id).count() != 0:
conflict = True conflict = True
conflict_names.append(name) conflict_names.append(name)
'''
if 'geoname' in data: if 'geoname' in data:
if models.Place.objects.filter(defined=True, if models.Place.objects.filter(defined=True,
geoname=data['geoname']).exclude(id=place.id).count() != 0: geoname=data['geoname']).exclude(id=place.id).count() != 0:
conflict = True conflict = True
conflict_geoname = data['geoname'] conflict_geoname = data['geoname']
'''
if not conflict: if not conflict:
models.Place.objects.filter(defined=False, name__in=names+alternative_names).delete() models.Place.objects.filter(defined=False, name__in=names+alternative_names).delete()
for key in data: for key in data:

View file

@ -241,10 +241,11 @@ pandora.ui.infoView = function(data) {
['country', 'year', 'language', 'runtime'].forEach(function(key) { ['country', 'year', 'language', 'runtime'].forEach(function(key) {
if (data[key]) { if (data[key]) {
html.push( html.push(
formatKey(key) formatKey(key) + (
+ (key == 'runtime' key != 'runtime' ? formatValue(data[key], key)
? Math.round(data[key] / 60) + ' min' : data[key] < 60 ? Math.round(data[key]) + ' sec'
: formatValue(data[key], key)) : Math.round(data[key] / 60) + ' min'
)
) )
} }
}); });