diff --git a/src/c3nav/editor/forms.py b/src/c3nav/editor/forms.py index e0939403..8e1cdc7c 100644 --- a/src/c3nav/editor/forms.py +++ b/src/c3nav/editor/forms.py @@ -404,7 +404,8 @@ def create_editor_form(editor_model): 'origin_space', 'target_space', 'data', 'comment', 'slow_down_factor', 'groundaltitude', 'node_number', 'wifi_bssid', 'bluetooth_address', "group", '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', 'label_settings', 'label_override', 'min_zoom', 'max_zoom', 'font_size', 'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois', 'allow_dynamic_locations', diff --git a/src/c3nav/mapdata/migrations/0113_locationgroup_can_report_mistake.py b/src/c3nav/mapdata/migrations/0113_locationgroup_can_report_mistake.py new file mode 100644 index 00000000..e9369acb --- /dev/null +++ b/src/c3nav/mapdata/migrations/0113_locationgroup_can_report_mistake.py @@ -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'), + ), + ] diff --git a/src/c3nav/mapdata/models/locations.py b/src/c3nav/mapdata/models/locations.py index 4e506ad6..2bba150a 100644 --- a/src/c3nav/mapdata/models/locations.py +++ b/src/c3nav/mapdata/models/locations.py @@ -317,6 +317,10 @@ class LocationGroup(Location, models.Model): SINGLE = "single", _("offer in first step, exclusive 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, verbose_name=_('Category')) priority = models.IntegerField(default=0, db_index=True) @@ -326,6 +330,8 @@ class LocationGroup(Location, models.Model): help_text=_('unless location specifies otherwise')) can_report_missing = models.CharField(_('report missing location'), choices=CanReportMissing.choices, 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, fallback_value="", help_text=_('to aid with selection in the report form')) diff --git a/src/c3nav/site/views.py b/src/c3nav/site/views.py index 4ce097bf..6f1bca2f 100644 --- a/src/c3nav/site/views.py +++ b/src/c3nav/site/views.py @@ -643,6 +643,14 @@ def report_create(request, coordinates=None, location=None, origin=None, destina elif location: report.category = 'location-issue' 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( + '{}

{}', + _('We do not accept reports for this location.'), + group.report_help_text, + )) + return render(request, 'site/report_question.html', {}) if report.location is None: raise Http404 if not isinstance(report.location, SpecificLocation):