diff --git a/pandora/place/views.py b/pandora/place/views.py index f3d176b87..083871170 100644 --- a/pandora/place/views.py +++ b/pandora/place/views.py @@ -40,6 +40,17 @@ def addPlace(request): existing_names = [] existing_geoname = '' name = data.pop('name') + if name == '': + _exists = True + name = 'Untitled' + n = 0 + while _exists: + _exists = models.Place.objects.filter(defined=True, + name_find__icontains=u'|%s|'%name).count() > 0 + if _exists: + name = 'Untitled [%s]' %n + n += 1 + names = [name] + data.get('alternativeNames', []) for name in names: if models.Place.objects.filter(defined=True, diff --git a/static/js/pandora/eventsDialog.js b/static/js/pandora/eventsDialog.js index 7ac884a0b..9c189f75d 100644 --- a/static/js/pandora/eventsDialog.js +++ b/static/js/pandora/eventsDialog.js @@ -84,7 +84,9 @@ pandora.ui.eventsDialog = function() { }); }, events: result.data.items, + hasMatches: true, height: height, + mode: pandora.site.calendar == 'auto' ? 'add' : 'define', removeEvent: function(event, callback) { pandora.api.removeEvent(event, function(result) { Ox.Request.clearCache(); // fixme: remove diff --git a/static/js/pandora/placesDialog.js b/static/js/pandora/placesDialog.js index d6d065e74..9ddb561c3 100644 --- a/static/js/pandora/placesDialog.js +++ b/static/js/pandora/placesDialog.js @@ -22,6 +22,7 @@ pandora.ui.placesDialog = function(options) { getMatches: function(names, callback) { // fixme: the results of this are of course // not identical to actual place matches + names.length == 0 && callback(0); var key = pandora.site.layers.filter(function(layer) { return layer.type == 'place' || layer.hasPlaces; }).map(function(layer) { @@ -40,6 +41,7 @@ pandora.ui.placesDialog = function(options) { callback(result.data.items); }); }, + hasMatches: true, // FIXME: getMatches is enough height: height - 48, mode: pandora.site.map == 'auto' ? 'add' : 'define', names: pandora.hasPlacesLayer ? function(callback) { @@ -59,7 +61,7 @@ pandora.ui.placesDialog = function(options) { callback(result); }); }, - selected: options ? options.id : void 0, + selected: options ? options.id : '', showControls: pandora.user.ui.showMapControls, showLabels: pandora.user.ui.showMapLabels, showTypes: true,