custom room enter description
This commit is contained in:
parent
79314849dd
commit
3fb4d7f4b8
5 changed files with 27 additions and 3 deletions
|
@ -227,7 +227,7 @@ def create_editor_form(editor_model):
|
|||
'base_altitude', 'waytype', 'access_restriction', 'height', 'default_height', 'door_height',
|
||||
'outside', 'can_search', 'can_describe', 'geometry', 'single', 'altitude', 'short_label',
|
||||
'origin_space', 'target_space', 'data', 'comment', 'slow_down_factor',
|
||||
'extra_seconds', 'speed', 'description', 'speed_up', 'description_up',
|
||||
'extra_seconds', 'speed', 'description', 'speed_up', 'description_up', 'enter_description',
|
||||
'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois', 'left', 'top', 'right', 'bottom']
|
||||
field_names = [field.name for field in editor_model._meta.get_fields() if not field.one_to_many]
|
||||
existing_fields = [name for name in possible_fields if name in field_names]
|
||||
|
|
|
@ -142,7 +142,7 @@ def get_i18n_value(i18n_dict, fallback_language, fallback_any, fallback_value):
|
|||
return i18n_dict[fallback_language]
|
||||
if fallback_any:
|
||||
return next(iter(i18n_dict.values()))
|
||||
return str(fallback_value)
|
||||
return None if fallback_value is None else str(fallback_value)
|
||||
|
||||
|
||||
lazy_get_i18n_value = lazy(get_i18n_value, str)
|
||||
|
|
21
src/c3nav/mapdata/migrations/0067_space_enter_description.py
Normal file
21
src/c3nav/mapdata/migrations/0067_space_enter_description.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.7 on 2017-12-22 15:13
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import c3nav.mapdata.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mapdata', '0066_area_slow_down_factor'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='space',
|
||||
name='enter_description',
|
||||
field=c3nav.mapdata.fields.I18nField(blank=True, fallback_language=None, verbose_name='Enter description'),
|
||||
),
|
||||
]
|
|
@ -16,7 +16,7 @@ from shapely.geometry import JOIN_STYLE, LineString, MultiPolygon
|
|||
from shapely.geometry.polygon import orient
|
||||
from shapely.ops import unary_union
|
||||
|
||||
from c3nav.mapdata.fields import GeometryField
|
||||
from c3nav.mapdata.fields import GeometryField, I18nField
|
||||
from c3nav.mapdata.models import Level
|
||||
from c3nav.mapdata.models.access import AccessRestrictionMixin
|
||||
from c3nav.mapdata.models.geometry.base import GeometryMixin
|
||||
|
@ -112,6 +112,7 @@ class Space(LevelGeometryMixin, SpecificLocation, models.Model):
|
|||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, null=True, blank=True,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
outside = models.BooleanField(default=False, verbose_name=_('only outside of building'))
|
||||
enter_description = I18nField(_('Enter description'), blank=True, fallback_language=None)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Space')
|
||||
|
|
|
@ -97,6 +97,8 @@ class Route:
|
|||
description = current_space.cross_descriptions.get((last_space.pk, next_space.pk), None)
|
||||
if description is None:
|
||||
description = current_space.leave_descriptions.get(next_space.pk, None)
|
||||
if description is None:
|
||||
description = item.space.enter_description
|
||||
if description is None:
|
||||
description = _('Go to %(space_title)s.') % {'space_title': item.space.title}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue