diff options
author | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
commit | 09dacfc6b8bf62addeee16c20b1d90c2a256da96 (patch) | |
tree | 7caa2bf9e92227ab74448f9b746dd28bbcb81b2a /perllib/FixMyStreet/Cobrand/Default.pm | |
parent | 585e57484f9c6332668bf1ac0a6a3b39dbe32223 (diff) | |
parent | cea89fb87a96943708a1db0f646492fbfaaf000f (diff) |
Merge tag 'v3.1' into fiksgatami-devfiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Default.pm')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 695487268..e58bceb2a 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -523,13 +523,29 @@ sub allow_update_reporting { return 0; } =item updates_disallowed Returns a boolean indicating whether updates on a particular report are allowed -or not. Default behaviour is disallowed if "closed_updates" metadata is set. +or not. Default behaviour is disallowed if "closed_updates" metadata is set, or +if the report's category has its "updates_disallowed" flag set. =cut sub updates_disallowed { my ($self, $problem) = @_; return 1 if $problem->get_extra_metadata('closed_updates'); + return 1 if $problem->contact && $problem->contact->get_extra_metadata('updates_disallowed'); + return 0; +} + +=item reopening_disallowed + +Returns a boolean indicating whether reopening of a particular report is +allowed or not. Default behaviour is allowed unless the report's category +has its reopening_disallowed flag set. + +=cut + +sub reopening_disallowed { + my ($self, $problem) = @_; + return 1 if $problem->contact && $problem->contact->get_extra_metadata('reopening_disallowed'); return 0; } @@ -941,11 +957,12 @@ Get stats to display on the council reports page sub get_report_stats { return 0; } sub get_body_sender { - my ( $self, $body, $category ) = @_; + my ( $self, $body, $problem ) = @_; # look up via category + my $category = $problem->category; my $contact = $body->contacts->search( { category => $category } )->first; - if ( $body->can_be_devolved && $contact->send_method ) { + if ( $body->can_be_devolved && $contact && $contact->send_method ) { return { method => $contact->send_method, config => $contact, contact => $contact }; } @@ -1055,7 +1072,7 @@ sub can_support_problems { return 0; } =item default_map_zoom default_map_zoom is used when displaying a map overriding the -default of max-4 or max-3 depending on population density. +default that depends on population density. =cut @@ -1107,7 +1124,22 @@ pressed in the front end, rather than whenever a username is not provided. =cut -sub allow_anonymous_reports { 0; } +sub allow_anonymous_reports { + my ($self, $category_name) = @_; + + $category_name ||= $self->{c}->stash->{category}; + if ( $category_name && $self->can('body') and $self->body ) { + my $category_rs = FixMyStreet::DB->resultset("Contact")->search({ + body_id => $self->body->id, + category => $category_name + }); + if ( my $category = $category_rs->first ) { + return 'button' if $category->get_extra_metadata('anonymous_allowed'); + } + } + + return 0; +} =item anonymous_account @@ -1216,15 +1248,13 @@ sub get_geocoder { sub problem_as_hashref { my $self = shift; my $problem = shift; - my $ctx = shift; - return $problem->as_hashref( $ctx ); + return $problem->as_hashref; } sub updates_as_hashref { my $self = shift; my $problem = shift; - my $ctx = shift; return {}; } @@ -1256,14 +1286,6 @@ sub category_extra_hidden { return 0; } -sub traffic_management_options { - return [ - _("Yes"), - _("No"), - ]; -} - - =item display_days_ago_threshold Used to control whether a relative 'n days ago' or absolute date is shown |