allow waytypes to be excluded by default
This commit is contained in:
parent
d5c7d50f78
commit
6428a39a04
5 changed files with 34 additions and 10 deletions
|
@ -406,7 +406,7 @@ def create_editor_form(editor_model):
|
|||
'node_number', 'wifi_bssid', 'bluetooth_address', "group",
|
||||
'ibeacon_uuid', 'ibeacon_major', 'ibeacon_minor', 'uwb_address',
|
||||
'extra_seconds', 'speed', 'can_report_missing', "can_report_mistake",
|
||||
'description', 'speed_up', 'description_up',
|
||||
'description', 'speed_up', 'description_up', 'avoid_by_default',
|
||||
'report_help_text', 'enter_description', 'level_change_description', 'base_mapdata_accessible',
|
||||
'label_settings', 'label_override', 'min_zoom', 'max_zoom', 'font_size', 'members',
|
||||
'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois', 'allow_dynamic_locations',
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 5.0.8 on 2024-12-15 18:23
|
||||
|
||||
import c3nav.mapdata.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mapdata', '0115_dataoverlay_access_restriction'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='waytype',
|
||||
name='avoid_by_default',
|
||||
field=models.BooleanField(default=False, verbose_name='avoid by default'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='waytype',
|
||||
name='description',
|
||||
field=c3nav.mapdata.fields.I18nField(fallback_any=True, verbose_name='description (downwards or general)'),
|
||||
),
|
||||
]
|
|
@ -41,11 +41,12 @@ class WayType(SerializableMixin, models.Model):
|
|||
up_separate = models.BooleanField(_('upwards separately'), default=True)
|
||||
walk = models.BooleanField(_('walking'), default=False)
|
||||
color = models.CharField(max_length=32, verbose_name=_('edge color'))
|
||||
avoid_by_default = models.BooleanField(_('avoid by default'), default=False)
|
||||
icon_name = models.CharField(_('icon name'), max_length=32, null=True, blank=True)
|
||||
extra_seconds = models.PositiveSmallIntegerField(_('extra seconds per edge'), default=0)
|
||||
speed = models.DecimalField(_('speed (m/s)'), max_digits=3, decimal_places=1, default=1,
|
||||
validators=[MinValueValidator(Decimal('0.1'))])
|
||||
description = I18nField(_('description'), fallback_any=True)
|
||||
description = I18nField(_('description (downwards or general)'), fallback_any=True)
|
||||
speed_up = models.DecimalField(_('speed upwards (m/s)'), max_digits=3, decimal_places=1, default=1,
|
||||
validators=[MinValueValidator(Decimal('0.1'))])
|
||||
description_up = I18nField(_('description upwards'), fallback_any=True)
|
||||
|
|
|
@ -52,7 +52,7 @@ class RouteOptions(models.Model):
|
|||
fields['waytype_%d' % waytype.pk] = forms.ChoiceField(
|
||||
label=waytype.title_plural,
|
||||
choices=tuple(choices),
|
||||
initial='allow'
|
||||
initial='avoid' if waytype.avoid_by_default else 'allow',
|
||||
)
|
||||
|
||||
fields['restrictions'] = forms.ChoiceField(
|
||||
|
|
|
@ -178,14 +178,14 @@ class Route:
|
|||
def options_summary(self):
|
||||
options_summary = [
|
||||
{
|
||||
'fastest': _('fastest route'),
|
||||
'shortest': _('shortest route')
|
||||
'fastest': _('fastest'),
|
||||
'shortest': _('shortest')
|
||||
}[self.options['mode']],
|
||||
]
|
||||
|
||||
restrictions_option = self.options.get('restrictions', 'normal')
|
||||
if restrictions_option == "avoid":
|
||||
options_summary.append(_('avoid restrictions'))
|
||||
options_summary.append(_('avoid restrictionss'))
|
||||
elif restrictions_option == "prefer":
|
||||
options_summary.append(_('prefer restrictions'))
|
||||
|
||||
|
@ -193,10 +193,9 @@ class Route:
|
|||
for name, value in self.options.items())
|
||||
|
||||
if waytypes_excluded:
|
||||
options_summary.append(_('some path types avoided'))
|
||||
|
||||
if len(options_summary) == 1:
|
||||
options_summary.append(_('default options'))
|
||||
options_summary.append(_('avoid some path types'))
|
||||
else:
|
||||
options_summary.append(_('all path types'))
|
||||
|
||||
return ', '.join(str(s) for s in options_summary)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue