fix some issues when c3nav is setup from ground up

This commit is contained in:
Laura Klünder 2018-11-16 00:52:13 +01:00
parent 417fd9514e
commit 27c833b3ef
3 changed files with 8 additions and 3 deletions

View file

@ -97,8 +97,8 @@ class BoundsMixin(SerializableMixin, models.Model):
return result return result
result = cls.objects.all().aggregate(models.Min('left'), models.Min('bottom'), result = cls.objects.all().aggregate(models.Min('left'), models.Min('bottom'),
models.Max('right'), models.Max('top')) models.Max('right'), models.Max('top'))
result = ((float(result['left__min']), float(result['bottom__min'])), result = ((float(result['left__min'] or 0), float(result['bottom__min'] or 0)),
(float(result['right__max']), float(result['top__max']))) (float(result['right__max'] or 10), float(result['top__max'] or 10)))
cache.set(cache_key, result, 900) cache.set(cache_key, result, 900)
return result return result

View file

@ -1000,8 +1000,10 @@ c3nav = {
if ($map.is('[data-initial-level]')) { if ($map.is('[data-initial-level]')) {
c3nav.initial_level = parseInt($map.attr('data-initial-level')); c3nav.initial_level = parseInt($map.attr('data-initial-level'));
} else { } else if (c3nav.levels.length) {
c3nav.initial_level = c3nav.levels[0][0]; c3nav.initial_level = c3nav.levels[0][0];
} else {
c3nav.initial_level = 0
} }
c3nav.level_labels_by_id = {}; c3nav.level_labels_by_id = {};

View file

@ -114,6 +114,9 @@ def map_index(request, mode=None, slug=None, slug2=None, details=None, options=N
}) })
initial_bounds = settings.INITIAL_BOUNDS initial_bounds = settings.INITIAL_BOUNDS
if not initial_bounds:
initial_bounds = (0, 0, 10, 10)
ctx = { ctx = {
'bounds': json.dumps(Source.max_bounds(), separators=(',', ':')), 'bounds': json.dumps(Source.max_bounds(), separators=(',', ':')),
'levels': json.dumps(tuple((level.pk, level.short_label) for level in levels.values()), separators=(',', ':')), 'levels': json.dumps(tuple((level.pk, level.short_label) for level in levels.values()), separators=(',', ':')),