can_report_mistake
This commit is contained in:
parent
7a39d5fae0
commit
9c72bec4e9
4 changed files with 34 additions and 1 deletions
|
@ -404,7 +404,8 @@ def create_editor_form(editor_model):
|
||||||
'origin_space', 'target_space', 'data', 'comment', 'slow_down_factor', 'groundaltitude',
|
'origin_space', 'target_space', 'data', 'comment', 'slow_down_factor', 'groundaltitude',
|
||||||
'node_number', 'wifi_bssid', 'bluetooth_address', "group",
|
'node_number', 'wifi_bssid', 'bluetooth_address', "group",
|
||||||
'ibeacon_uuid', 'ibeacon_major', 'ibeacon_minor', 'uwb_address',
|
'ibeacon_uuid', 'ibeacon_major', 'ibeacon_minor', 'uwb_address',
|
||||||
'extra_seconds', 'speed', 'can_report_missing', 'description', 'speed_up', 'description_up',
|
'extra_seconds', 'speed', 'can_report_missing', "can_report_mistake",
|
||||||
|
'description', 'speed_up', 'description_up',
|
||||||
'report_help_text', 'enter_description', 'level_change_description', 'base_mapdata_accessible',
|
'report_help_text', 'enter_description', 'level_change_description', 'base_mapdata_accessible',
|
||||||
'label_settings', 'label_override', 'min_zoom', 'max_zoom', 'font_size',
|
'label_settings', 'label_override', 'min_zoom', 'max_zoom', 'font_size',
|
||||||
'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois', 'allow_dynamic_locations',
|
'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois', 'allow_dynamic_locations',
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.8 on 2024-12-09 15:01
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mapdata', '0112_alter_dataoverlay_options_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='locationgroup',
|
||||||
|
name='can_report_mistake',
|
||||||
|
field=models.CharField(choices=[('allow', "don't offer"), ('reject', 'reject for all locations with this group')], default='allow', max_length=16, verbose_name='report mistakes'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -317,6 +317,10 @@ class LocationGroup(Location, models.Model):
|
||||||
SINGLE = "single", _("offer in first step, exclusive choice")
|
SINGLE = "single", _("offer in first step, exclusive choice")
|
||||||
MULTIPLE = "multiple", _("offer if nothing in the first step matches, multiple choice")
|
MULTIPLE = "multiple", _("offer if nothing in the first step matches, multiple choice")
|
||||||
|
|
||||||
|
class CanReportMistake(models.TextChoices):
|
||||||
|
ALLOW = "allow", _("don't offer")
|
||||||
|
REJECT = "reject", _("reject for all locations with this group")
|
||||||
|
|
||||||
category = models.ForeignKey(LocationGroupCategory, related_name='groups', on_delete=models.PROTECT,
|
category = models.ForeignKey(LocationGroupCategory, related_name='groups', on_delete=models.PROTECT,
|
||||||
verbose_name=_('Category'))
|
verbose_name=_('Category'))
|
||||||
priority = models.IntegerField(default=0, db_index=True)
|
priority = models.IntegerField(default=0, db_index=True)
|
||||||
|
@ -326,6 +330,8 @@ class LocationGroup(Location, models.Model):
|
||||||
help_text=_('unless location specifies otherwise'))
|
help_text=_('unless location specifies otherwise'))
|
||||||
can_report_missing = models.CharField(_('report missing location'), choices=CanReportMissing.choices,
|
can_report_missing = models.CharField(_('report missing location'), choices=CanReportMissing.choices,
|
||||||
default=CanReportMissing.DONT_OFFER, max_length=16)
|
default=CanReportMissing.DONT_OFFER, max_length=16)
|
||||||
|
can_report_mistake = models.CharField(_('report mistakes'), choices=CanReportMistake.choices,
|
||||||
|
default=CanReportMistake.ALLOW, max_length=16)
|
||||||
|
|
||||||
description = I18nField(_('description'), plural_name='descriptions', blank=True, fallback_any=True,
|
description = I18nField(_('description'), plural_name='descriptions', blank=True, fallback_any=True,
|
||||||
fallback_value="", help_text=_('to aid with selection in the report form'))
|
fallback_value="", help_text=_('to aid with selection in the report form'))
|
||||||
|
|
|
@ -643,6 +643,14 @@ def report_create(request, coordinates=None, location=None, origin=None, destina
|
||||||
elif location:
|
elif location:
|
||||||
report.category = 'location-issue'
|
report.category = 'location-issue'
|
||||||
report.location = get_report_location_for_request(location, request)
|
report.location = get_report_location_for_request(location, request)
|
||||||
|
for group in report.location.groups.all():
|
||||||
|
if group.can_report_mistake == LocationGroup.CanReportMistake.REJECT:
|
||||||
|
messages.error(request, format_html(
|
||||||
|
'{}<br><br>{}',
|
||||||
|
_('We do not accept reports for this location.'),
|
||||||
|
group.report_help_text,
|
||||||
|
))
|
||||||
|
return render(request, 'site/report_question.html', {})
|
||||||
if report.location is None:
|
if report.location is None:
|
||||||
raise Http404
|
raise Http404
|
||||||
if not isinstance(report.location, SpecificLocation):
|
if not isinstance(report.location, SpecificLocation):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue