aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2021-10-07 13:32:40 +0200
committerMarius Halden <marius.h@lden.org>2021-10-07 13:32:40 +0200
commit09dacfc6b8bf62addeee16c20b1d90c2a256da96 (patch)
tree7caa2bf9e92227ab74448f9b746dd28bbcb81b2a /perllib/FixMyStreet/Cobrand/FixMyStreet.pm
parent585e57484f9c6332668bf1ac0a6a3b39dbe32223 (diff)
parentcea89fb87a96943708a1db0f646492fbfaaf000f (diff)
Merge tag 'v3.1' into fiksgatami-devfiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/FixMyStreet.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm96
1 files changed, 63 insertions, 33 deletions
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index dfb511f39..ae96924d8 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -35,15 +35,19 @@ sub restriction {
return {};
}
-# FixMyStreet needs to not show TfL reports...
+# FixMyStreet needs to not show TfL reports or Bromley waste reports
sub problems_restriction {
my ($self, $rs) = @_;
my $table = ref $rs eq 'FixMyStreet::DB::ResultSet::Nearby' ? 'problem' : 'me';
- return $rs->search({ "$table.cobrand" => { '!=' => 'tfl' } });
+ return $rs->search({
+ "$table.cobrand" => { '!=' => 'tfl' },
+ "$table.cobrand_data" => { '!=' => 'waste' },
+ });
}
sub problems_sql_restriction {
my $self = shift;
return "AND cobrand != 'tfl'";
+ # Doesn't need Bromley one as all waste reports non-public
}
sub relative_url_for_report {
@@ -54,32 +58,40 @@ sub relative_url_for_report {
sub munge_around_category_where {
my ($self, $where) = @_;
+ my $iow = grep { $_->name eq 'Isle of Wight Council' } @{ $self->{c}->stash->{around_bodies} };
+ if ($iow) {
+ # display all the categories on Isle of Wight at the moment as there's no way to
+ # do the expand bit later as we fetch it using ajax which uses a bounding box so
+ # can't determine the body
+ $where->{send_method} = [ { '!=' => 'Triage' }, undef ];
+ }
+ my $bromley = grep { $_->name eq 'Bromley Council' } @{ $self->{c}->stash->{around_bodies} };
+ if ($bromley) {
+ $where->{extra} = [ undef, { -not_like => '%Waste%' } ];
+ }
+}
+
+sub _iow_category_munge {
+ my ($self, $body, $categories) = @_;
my $user = $self->{c}->user;
- my @iow = grep { $_->name eq 'Isle of Wight Council' } @{ $self->{c}->stash->{around_bodies} };
- return unless @iow;
-
- # display all the categories on Isle of Wight at the moment as there's no way to
- # do the expand bit later as we fetch it using ajax which uses a bounding box so
- # can't determine the body
- $where->{send_method} = [ { '!=' => 'Triage' }, undef ];
- return $where;
+
+ if ( $user && ( $user->is_superuser || $user->belongs_to_body( $body->id ) ) ) {
+ @$categories = grep { !$_->send_method || $_->send_method ne 'Triage' } @$categories;
+ return;
+ }
+
+ @$categories = grep { $_->send_method && $_->send_method eq 'Triage' } @$categories;
}
-sub munge_reports_categories_list {
+sub munge_reports_category_list {
my ($self, $categories) = @_;
my %bodies = map { $_->body->name => $_->body } @$categories;
- if ( $bodies{'Isle of Wight Council'} ) {
- my $user = $self->{c}->user;
- my $b = $bodies{'Isle of Wight Council'};
-
- if ( $user && ( $user->is_superuser || $user->belongs_to_body( $b->id ) ) ) {
- @$categories = grep { !$_->send_method || $_->send_method ne 'Triage' } @$categories;
- return @$categories;
- }
-
- @$categories = grep { $_->send_method && $_->send_method eq 'Triage' } @$categories;
- return @$categories;
+ if ( my $body = $bodies{'Isle of Wight Council'} ) {
+ return $self->_iow_category_munge($body, $categories);
+ }
+ if ( $bodies{'Bromley Council'} ) {
+ @$categories = grep { grep { $_ ne 'Waste' } @{$_->groups} } @$categories;
}
}
@@ -118,16 +130,12 @@ sub munge_report_new_contacts {
my %bodies = map { $_->body->name => $_->body } @$contacts;
- if ( $bodies{'Isle of Wight Council'} ) {
- my $user = $self->{c}->user;
- if ( $user && ( $user->is_superuser || $user->belongs_to_body( $bodies{'Isle of Wight Council'}->id ) ) ) {
- @$contacts = grep { !$_->send_method || $_->send_method ne 'Triage' } @$contacts;
- return;
- }
-
- @$contacts = grep { $_->send_method && $_->send_method eq 'Triage' } @$contacts;
+ if ( my $body = $bodies{'Isle of Wight Council'} ) {
+ return $self->_iow_category_munge($body, $contacts);
+ }
+ if ( $bodies{'Bromley Council'} ) {
+ @$contacts = grep { grep { $_ ne 'Waste' } @{$_->groups} } @$contacts;
}
-
if ( $bodies{'TfL'} ) {
# Presented categories vary if we're on/off a red route
my $tfl = FixMyStreet::Cobrand->get_class_for_moniker( 'tfl' )->new({ c => $self->{c} });
@@ -139,10 +147,10 @@ sub munge_report_new_contacts {
sub munge_load_and_group_problems {
my ($self, $where, $filter) = @_;
- return unless $where->{category} && $self->{c}->stash->{body}->name eq 'Isle of Wight Council';
+ return unless $where->{'me.category'} && $self->{c}->stash->{body}->name eq 'Isle of Wight Council';
my $iow = FixMyStreet::Cobrand->get_class_for_moniker( 'isleofwight' )->new({ c => $self->{c} });
- $where->{category} = $iow->expand_triage_cat_list($where->{category}, $self->{c}->stash->{body});
+ $where->{'me.category'} = $iow->expand_triage_cat_list($where->{'me.category'}, $self->{c}->stash->{body});
}
sub title_list {
@@ -310,6 +318,19 @@ sub updates_disallowed {
return $self->next::method(@_);
}
+sub problem_state_processed {
+ my ($self, $comment) = @_;
+
+ my $state = $comment->problem_state || '';
+ my $code = $comment->get_extra_metadata('external_status_code') || '';
+
+ my ($cfg) = $self->per_body_config('extra_state_mapping', $comment->problem);
+
+ $state = ( $cfg->{$state}->{$code} || $state ) if $cfg->{$state};
+
+ return $state;
+}
+
sub suppress_reporter_alerts {
my $self = shift;
my $c = $self->{c};
@@ -347,4 +368,13 @@ sub manifest {
};
}
+sub report_new_munge_before_insert {
+ my ($self, $report) = @_;
+
+ # Make sure TfL reports are marked safety critical
+ $self->SUPER::report_new_munge_before_insert($report);
+
+ FixMyStreet::Cobrand::Buckinghamshire::report_new_munge_before_insert($self, $report);
+}
+
1;