diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/IsleOfWight.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Northamptonshire.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/TfL.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 2 |
8 files changed, 30 insertions, 29 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index 3a4480e85..058fa3806 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -548,13 +548,15 @@ sub heatmap_filters :Private { my ($self, $c, $where) = @_; # Wards - my @areas = @{$c->user->area_ids || []}; - # Want to get everything if nothing given in an ajax call - if (!$c->stash->{wards} && @areas) { - $c->stash->{wards} = [ map { { id => $_ } } @areas ]; - $where->{areas} = [ - map { { 'like', '%,' . $_ . ',%' } } @areas - ]; + if ($c->user_exists) { + my @areas = @{$c->user->area_ids || []}; + # Want to get everything if nothing given in an ajax call + if (!$c->stash->{wards} && @areas) { + $c->stash->{wards} = [ map { { id => $_ } } @areas ]; + $where->{areas} = [ + map { { 'like', '%,' . $_ . ',%' } } @areas + ]; + } } # Date range @@ -588,9 +590,14 @@ sub heatmap_sidebar :Private { my $params = { map { my $n = $_; s/me\./problem\./; $_ => $where->{$n} } keys %$where }; my $body = $c->stash->{body}; + + my @user; + push @user, $c->user->id if $c->user_exists; + push @user, $body->comment_user_id if $body->comment_user_id; + $params->{'me.user_id'} = { -not_in => \@user } if @user; + my @c = $c->model('DB::Comment')->to_body($body)->search({ %$params, - 'me.user_id' => { -not_in => [ $c->user->id, $body->comment_user_id || () ] }, 'me.state' => 'confirmed', }, { columns => 'problem_id', diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index cbbf8971a..ba37a25fa 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -691,6 +691,8 @@ sub setup_categories_and_bodies : Private { ->search( { 'me.body_id' => [ keys %bodies ] }, { prefetch => 'body' } ); my @contacts = $c->cobrand->categories_restriction($contacts)->all_sorted; + $c->cobrand->call_hook(munge_report_new_contacts => \@contacts); + # variables to populate my %bodies_to_list = (); # Bodies with categories assigned my @category_options = (); # categories to show diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index 6e0a0e2a5..fcbeebb48 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -83,8 +83,8 @@ sub munge_reports_categories_list { } } -sub munge_report_new_category_list { - my ($self, $options, $contacts, $extras) = @_; +sub munge_report_new_contacts { + my ($self, $contacts) = @_; my %bodies = map { $_->body->name => $_->body } @$contacts; @@ -92,20 +92,16 @@ sub munge_report_new_category_list { 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; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; return; } @$contacts = grep { $_->send_method && $_->send_method eq 'Triage' } @$contacts; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; } 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} }); - $tfl->munge_red_route_categories($options, $contacts); + $tfl->munge_red_route_categories($contacts); } } diff --git a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm index ab79be832..a46b540ad 100644 --- a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm +++ b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm @@ -108,8 +108,8 @@ sub munge_reports_category_list { return @$categories; } -sub munge_report_new_category_list { - my ($self, $options, $contacts, $extras) = @_; +sub munge_report_new_contacts { + my ($self, $contacts) = @_; my $user = $self->{c}->user; my %bodies = map { $_->body->name => $_->body } @$contacts; @@ -117,14 +117,10 @@ sub munge_report_new_category_list { if ( $user && ( $user->is_superuser || $user->belongs_to_body( $b->id ) ) ) { @$contacts = grep { !$_->send_method || $_->send_method ne 'Triage' } @$contacts; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; return; } @$contacts = grep { $_->send_method && $_->send_method eq 'Triage' } @$contacts; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; } sub munge_around_category_where { diff --git a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm index 60def9e15..bfcbf5af0 100644 --- a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm +++ b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm @@ -36,6 +36,8 @@ sub on_map_default_status { 'open' } sub report_sent_confirmation_email { 'id' } +sub admin_user_domain { 'northamptonshire.gov.uk' } + has body_obj => ( is => 'lazy', default => sub { diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm index 10c94f5cc..320f35991 100644 --- a/perllib/FixMyStreet/Cobrand/TfL.pm +++ b/perllib/FixMyStreet/Cobrand/TfL.pm @@ -440,10 +440,10 @@ sub report_new_is_on_tlrn { return scalar @$features ? 1 : 0; } -sub munge_report_new_category_list { } +sub munge_report_new_contacts { } sub munge_red_route_categories { - my ($self, $options, $contacts) = @_; + my ($self, $contacts) = @_; if ( $self->report_new_is_on_tlrn ) { # We're on a red route - only send TfL categories (except the disabled # one that directs the user to borough for street cleaning) and borough @@ -461,8 +461,6 @@ sub munge_red_route_categories { $tlrn_cats{$self->_tfl_council_category} = 1; @$contacts = grep { !( $_->body->name eq 'TfL' && $tlrn_cats{$_->category } ) } @$contacts; } - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; } # Reports in these categories can only be made on a red route diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 97c8b6c81..7336e60ca 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -289,14 +289,14 @@ sub prefill_report_fields_for_inspector { 1 } sub social_auth_disabled { 1 } -sub munge_report_new_category_list { - my ($self, $options, $contacts, $extras) = @_; +sub munge_report_new_contacts { + my ($self, $contacts) = @_; my %bodies = map { $_->body->name => $_->body } @$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} }); - $tfl->munge_red_route_categories($options, $contacts); + $tfl->munge_red_route_categories($contacts); } } diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 5c8ae4e28..5bb975104 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -68,7 +68,7 @@ sub uniquify_email { my ($self, $email, $file) = @_; $file = (caller)[1] unless $file; - (my $pkg = $file) =~ s{/}{}g; + (my $pkg = $file) =~ s{[/\.]}{}g; if ($email =~ /@/ && $email !~ /^pkg-/) { $email = "pkg-$pkg-$email"; |