diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-08-23 13:58:34 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-08-31 15:37:09 +0100 |
commit | 986c97311c4cb1f3ec092c0605dcb15ab2527da1 (patch) | |
tree | 870c91b9c680a30c42109d5d93aefdb164b6f819 | |
parent | 27110ac506f071ad0c5925ef74de1321514c23c8 (diff) |
Remove hardcoded states from templates.
State display names are now got from the database wherever they are
displayed, including admin dropdowns, list filters, and update meta
statements. This also covers the open/closed/fixed 'groups'.
This also fixes a bug whereby if e.g. an update has problem_state
investigating, the next update has no problem_state, and the last
update has investigating again, it was previously showing a state
change to investigating on that third update.
22 files changed, 142 insertions, 204 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index fbe5a2dc9..f3989e760 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -24,6 +24,8 @@ sub example : Local : Args(0) { my ( $self, $c ) = @_; $c->stash->{template} = 'dashboard/index.html'; + $c->stash->{filter_states} = $c->cobrand->state_groups_inspect; + $c->stash->{children} = {}; for my $i (1..3) { $c->stash->{children}{$i} = { id => $i, name => "Ward $i" }; @@ -93,6 +95,7 @@ sub index : Path : Args(0) { $c->stash->{body} = $body; # Set up the data for the dropdowns + $c->stash->{filter_states} = $c->cobrand->state_groups_inspect; # Just take the first area ID we find my $area_id = $body->body_areas->first->area_id; @@ -145,12 +148,10 @@ sub index : Path : Args(0) { # List of reports underneath summary table $c->stash->{q_state} = $c->get_param('state') || ''; - if ( $c->stash->{q_state} eq 'fixed' ) { + if ( $c->stash->{q_state} eq 'fixed - council' ) { $prob_where->{'me.state'} = [ FixMyStreet::DB::Result::Problem->fixed_states() ]; } elsif ( $c->stash->{q_state} ) { $prob_where->{'me.state'} = $c->stash->{q_state}; - $prob_where->{'me.state'} = { IN => [ 'planned', 'action scheduled' ] } - if $prob_where->{'me.state'} eq 'action scheduled'; } my $params = { %$prob_where, diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index b597cb7a8..8f8205719 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -558,12 +558,11 @@ sub stash_report_filter_status : Private { if ($c->user and ($c->user->is_superuser or ( $c->stash->{body} and $c->user->belongs_to_body($c->stash->{body}->id) ))) { + $c->stash->{filter_states} = $c->cobrand->state_groups_inspect; foreach my $state (FixMyStreet::DB::Result::Problem->visible_states()) { if ($status{$state}) { - %filter_problem_states = (%filter_problem_states, ($state => 1)); - my $pretty_state = $state; - $pretty_state =~ tr/ /_/; - $filter_status{$pretty_state} = 1; + $filter_problem_states{$state} = 1; + $filter_status{$state} = 1; } } } diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index 93c459e26..93aa0e2fb 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -170,12 +170,8 @@ sub decode { sub prettify_state { my ($self, $c, $text, $single_fixed) = @_; - # New template to prevent interaction with current one - my $tt = FixMyStreet::Template->new({ INCLUDE_PATH => $self->{include_path} }); - my $var; - $tt->process('report/state-list.html', { state => $text }, \$var); - $var =~ s/ - .*// if $single_fixed; - return $var; + + return FixMyStreet::DB->resultset("State")->display($text, $single_fixed); } 1; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 5dcdc9a4b..4e5228a25 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -179,7 +179,7 @@ sub restriction { return $self->moniker ? { cobrand => $self->moniker } : {}; } -=head2 base_url_with_lang +=head2 base_url_with_lang =cut @@ -358,7 +358,7 @@ sub front_stats_data { Returns any disambiguating information available. Defaults to none. -=cut +=cut sub disambiguate_location { FixMyStreet->config('GEOCODING_DISAMBIGUATION') or {}; } @@ -820,7 +820,7 @@ sub is_two_tier { 0; } =item council_rss_alert_options -Generate a set of options for council rss alerts. +Generate a set of options for council rss alerts. =cut @@ -1066,6 +1066,28 @@ sub show_unconfirmed_reports { 0; } +sub state_groups_admin { + my $rs = FixMyStreet::DB->resultset("State"); + my @fixed = FixMyStreet::DB::Result::Problem->fixed_states; + [ + [ $rs->display('confirmed'), [ FixMyStreet::DB::Result::Problem->open_states ] ], + @fixed ? [ $rs->display('fixed'), [ FixMyStreet::DB::Result::Problem->fixed_states ] ] : (), + [ $rs->display('closed'), [ FixMyStreet::DB::Result::Problem->closed_states ] ], + [ $rs->display('hidden'), [ FixMyStreet::DB::Result::Problem->hidden_states ] ] + ] +} + +sub state_groups_inspect { + my $rs = FixMyStreet::DB->resultset("State"); + my @fixed = FixMyStreet::DB::Result::Problem->fixed_states; + [ + [ $rs->display('confirmed'), [ grep { $_ ne 'planned' } FixMyStreet::DB::Result::Problem->open_states ] ], + @fixed ? [ $rs->display('fixed'), [ 'fixed - council' ] ] : (), + [ $rs->display('closed'), [ grep { $_ ne 'closed' } FixMyStreet::DB::Result::Problem->closed_states ] ], + [ $rs->display('hidden'), [ 'hidden' ] ] + ] +} + =head2 never_confirm_updates If true then we never send an email to confirm an update diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index a061ff46c..b3d6b28c3 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -122,12 +122,19 @@ sub path_to_pin_icons { sub pin_hover_title { my ($self, $problem, $title) = @_; - my $state = $self->{c}->render_fragment( - 'report/state-list.html', - { state => $problem->state }); + my $state = FixMyStreet::DB->resultset("State")->display($problem->state, 1); return "$state: $title"; } +sub state_groups_inspect { + [ + [ _('New'), [ 'confirmed', 'investigating' ] ], + [ _('Scheduled'), [ 'action scheduled' ] ], + [ _('Fixed'), [ 'fixed - council' ] ], + [ _('Closed'), [ 'not responsible', 'duplicate', 'unable to fix' ] ], + ] +} + sub open311_config { my ($self, $row, $h, $params) = @_; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index d688eb8b9..562f29693 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -227,8 +227,6 @@ sub meta_line { my $meta = ''; - $c->stash->{last_state} ||= ''; - if ($self->anonymous or !$self->name) { $meta = sprintf( _( 'Posted anonymously at %s' ), Utils::prettify_dt( $self->confirmed ) ) } elsif ($self->user->from_body) { @@ -257,60 +255,36 @@ sub meta_line { $meta = sprintf( _( 'Posted by %s at %s' ), FixMyStreet::Template::html_filter($self->name), Utils::prettify_dt( $self->confirmed ) ) } + if ($self->get_extra_metadata('defect_raised')) { + $meta .= ', ' . _( 'and a defect raised' ); + } + + return $meta; +}; + +sub problem_state_display { + my ( $self, $c ) = @_; + my $update_state = ''; + my $cobrand = $c->cobrand->moniker; if ($self->mark_fixed) { - $update_state = _( 'marked as fixed' ); + return FixMyStreet::DB->resultset("State")->display('fixed', 1); } elsif ($self->mark_open) { - $update_state = _( 'reopened' ); + return FixMyStreet::DB->resultset("State")->display('confirmed', 1); } elsif ($self->problem_state) { my $state = $self->problem_state; - - if ($state eq 'confirmed') { - if ($c->stash->{last_state}) { - $update_state = _( 'reopened' ) - } - } elsif ($state eq 'investigating') { - $update_state = _( 'marked as investigating' ) - } elsif ($state eq 'planned') { - $update_state = _( 'marked as planned' ) - } elsif ($state eq 'in progress') { - $update_state = _( 'marked as in progress' ) - } elsif ($state eq 'action scheduled') { - $update_state = _( 'marked as action scheduled' ) - } elsif ($state eq 'closed') { - $update_state = _( 'marked as closed' ) - } elsif ($state =~ /^fixed/) { - $update_state = _( 'marked as fixed' ) - } elsif ($state eq 'unable to fix') { - $update_state = _( 'marked as no further action' ) - } elsif ($state eq 'not responsible') { - $update_state = _( "marked as not the council's responsibility" ) - } elsif ($state eq 'duplicate') { - $update_state = _( 'closed as a duplicate report' ) - } elsif ($state eq 'internal referral') { - $update_state = _( 'marked as an internal referral' ) - } - - if ($c->cobrand->moniker eq 'bromley' || $self->problem->to_body_named('Bromley')) { - if ($state eq 'not responsible') { - $update_state = 'marked as third party responsibility' + if ($state eq 'not responsible') { + $update_state = _( "not the council's responsibility" ); + if ($cobrand eq 'bromley' || $self->problem->to_body_named('Bromley')) { + $update_state = 'third party responsibility'; } + } else { + $update_state = FixMyStreet::DB->resultset("State")->display($state, 1); } - } - if ($update_state ne $c->stash->{last_state} and $update_state) { - $meta .= ", $update_state"; - } - - if ($self->get_extra_metadata('defect_raised')) { - $meta .= ', ' . _( 'and a defect raised' ); - } - - $c->stash->{last_state} = $update_state; - - return $meta; -}; + return $update_state; +} 1; diff --git a/perllib/FixMyStreet/DB/ResultSet/State.pm b/perllib/FixMyStreet/DB/ResultSet/State.pm index 03bbb5e3b..8b6a8963e 100644 --- a/perllib/FixMyStreet/DB/ResultSet/State.pm +++ b/perllib/FixMyStreet/DB/ResultSet/State.pm @@ -54,7 +54,7 @@ sub fixed { [ $_[0]->_filter(sub { $_->type eq 'fixed' }) ] } # This function can be used to return that label's display name. sub display { - my ($rs, $label) = @_; + my ($rs, $label, $single_fixed) = @_; my $unchanging = { unconfirmed => _("Unconfirmed"), hidden => _("Hidden"), @@ -62,6 +62,7 @@ sub display { 'fixed - council' => _("Fixed - Council"), 'fixed - user' => _("Fixed - User"), }; + $label = 'fixed' if $single_fixed && $label =~ /^fixed - (council|user)$/; return $unchanging->{$label} if $unchanging->{$label}; my ($state) = $rs->_filter(sub { $_->label eq $label }); return $label unless $state; diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 9d424c1ae..b87b58b38 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -545,22 +545,11 @@ FixMyStreet::override_config { }, { desc => 'limit by state works', - state => 'fixed', + state => 'fixed - council', report_counts => [2,0,0], report_counts_after => [1,0,0], }, { - desc => 'planned counted as action scheduled', - p1 => { - state => 'planned', - conf_dt => DateTime->now(), - category => 'Potholes', - }, - state => 'action scheduled', - report_counts => [3,0,0], - report_counts_after => [1,0,0], - }, - { desc => 'All fixed states count as fixed', p1 => { state => 'fixed - council', @@ -573,7 +562,7 @@ FixMyStreet::override_config { category => 'Potholes', }, state => 'fixed', - report_counts => [5,0,0], + report_counts => [4,0,0], report_counts_after => [3,0,0], }, ) { @@ -612,7 +601,7 @@ FixMyStreet::override_config { while ( my $row = $csv->getline( $data_handle ) ) { push @rows, $row; } - is scalar @rows, 7, '1 (header) + 6 (reports) = 7 lines'; + is scalar @rows, 6, '1 (header) + 5 (reports) = 6 lines'; }; }; restore_time; diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 093ea9cf8..4d73a5204 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -313,7 +313,7 @@ for my $test ( date => DateTime->now, state => 'investigating', banner_id => 'progress', - banner_text => 'progress', + banner_text => 'investigating', fixed => 0 }, { @@ -321,7 +321,7 @@ for my $test ( date => DateTime->now, state => 'action scheduled', banner_id => 'progress', - banner_text => 'progress', + banner_text => 'action scheduled', fixed => 0 }, { @@ -329,7 +329,7 @@ for my $test ( date => DateTime->now, state => 'planned', banner_id => 'progress', - banner_text => 'progress', + banner_text => 'planned', fixed => 0 }, { diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 687692679..4000a9da8 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -90,9 +90,8 @@ FixMyStreet::override_config { is $report->user->get_extra_metadata('reputation'), $reputation, "User reputation wasn't changed"; $mech->get_ok("/report/$report_id"); my $meta = $mech->extract_update_metas; - like $meta->[0], qr/Updated by .*action scheduled/, 'First update mentions action scheduled'; - like $meta->[1], qr/Posted by .*defect raised/, 'Update mentions defect raised'; - unlike $meta->[2], qr/Posted by .*action scheduled/, 'Update does not mention action scheduled'; + like $meta->[0], qr/State changed to: Action scheduled/, 'First update mentions action scheduled'; + like $meta->[2], qr/Posted by .*defect raised/, 'Update mentions defect raised'; $user->unset_extra_metadata('categories'); $user->update; diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 4cb035bac..7c262fbe6 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -93,8 +93,7 @@ for my $test ( anonymous => 't', mark_fixed => 'true', mark_open => 'false', - meta => -'Posted anonymously at 15:47, Sat 16 April 2011, marked as fixed', + meta => [ 'State changed to: Fixed', 'Posted anonymously at 15:47, Sat 16 April 2011' ] }, { description => 'named user, anon is true, reopened', @@ -102,7 +101,7 @@ for my $test ( anonymous => 't', mark_fixed => 'false', mark_open => 'true', - meta => 'Posted anonymously at 15:47, Sat 16 April 2011, reopened', + meta => [ 'State changed to: Open', 'Posted anonymously at 15:47, Sat 16 April 2011' ] } ) { @@ -118,8 +117,9 @@ for my $test ( $mech->content_contains('This is some update text'); my $meta = $mech->extract_update_metas; - is scalar @$meta, 1, 'number of updates'; - is $meta->[0], $test->{meta}; + my $test_meta = ref $test->{meta} ? $test->{meta} : [ $test->{meta} ]; + is scalar @$meta, scalar @$test_meta, 'number of updates'; + is_deeply $meta, $test_meta; }; } @@ -131,7 +131,7 @@ subtest "updates displayed on report with empty bodies_str" => sub { $mech->get_ok("/report/$report_id"); my $meta = $mech->extract_update_metas; - is scalar @$meta, 1, 'update displayed'; + is scalar @$meta, 2, 'update displayed'; $report->update({ bodies_str => $old_bodies_str }); }; @@ -185,10 +185,11 @@ subtest "several updates shown in correct order" => sub { $mech->get_ok("/report/$report_id"); my $meta = $mech->extract_update_metas; - is scalar @$meta, 3, 'number of updates'; + is scalar @$meta, 4, 'number of updates'; is $meta->[0], 'Posted by Other User at 12:23, Thu 10 March 2011', 'first update'; is $meta->[1], 'Posted by Main User at 12:23, Thu 10 March 2011', 'second update'; - is $meta->[2], 'Posted anonymously at 08:12, Tue 15 March 2011, marked as fixed', 'third update'; + is $meta->[2], 'State changed to: Fixed', 'third update, part 1'; + is $meta->[3], 'Posted anonymously at 08:12, Tue 15 March 2011', 'third update, part 2'; }; for my $test ( @@ -613,7 +614,6 @@ for my $test ( state => 'internal referral', }, state => 'internal referral', - meta => "an internal referral", }, { desc => 'from authority user marks report as not responsible', @@ -635,7 +635,6 @@ for my $test ( state => 'duplicate', }, state => 'duplicate', - meta => 'a duplicate report', }, { desc => 'from authority user marks report as internal referral', @@ -646,7 +645,6 @@ for my $test ( state => 'internal referral', }, state => 'internal referral', - meta => 'an internal referral', }, { desc => 'from authority user marks report sent to two councils as fixed', @@ -711,19 +709,13 @@ for my $test ( my $update_meta = $mech->extract_update_metas; my $meta_state = $test->{meta} || $test->{fields}->{state}; - if ( $test->{reopened} ) { - like $update_meta->[0], qr/reopened/, 'update meta says reopened'; - } elsif ( $test->{state} eq 'duplicate' ) { - like $update_meta->[0], qr/closed as $meta_state/, 'update meta includes state change'; - } else { - like $update_meta->[0], qr/marked as $meta_state/, 'update meta includes state change'; - } + like $update_meta->[0], qr/$meta_state/i, 'update meta includes state change'; if ($test->{view_username}) { - like $update_meta->[0], qr{Westminster City Council \(Test User\)}, 'update meta includes council and user name'; + like $update_meta->[1], qr{Westminster City Council \(Test User\)}, 'update meta includes council and user name'; $user->user_body_permissions->delete_all; } else { - like $update_meta->[0], qr{Westminster City Council}, 'update meta includes council name'; + like $update_meta->[1], qr{Westminster City Council}, 'update meta includes council name'; $mech->content_contains( '<strong>Westminster City Council</strong>', 'council name in bold'); } @@ -751,24 +743,22 @@ subtest 'check meta correct for comments marked confirmed but not marked open' = $mech->get_ok( "/report/" . $report->id ); my $update_meta = $mech->extract_update_metas; - unlike $update_meta->[0], qr/reopened/, + unlike $update_meta->[0], qr/Open/, 'update meta does not say reopened'; $comment->update( { mark_open => 1, problem_state => undef } ); $mech->get_ok( "/report/" . $report->id ); $update_meta = $mech->extract_update_metas; - unlike $update_meta->[0], qr/marked as open/, - 'update meta does not says marked as open'; - like $update_meta->[0], qr/reopened/, 'update meta does say reopened'; + like $update_meta->[0], qr/Open/, 'update meta does say open'; $comment->update( { mark_open => 0, problem_state => undef } ); $mech->get_ok( "/report/" . $report->id ); $update_meta = $mech->extract_update_metas; - unlike $update_meta->[0], qr/marked as open/, + unlike $update_meta->[0], qr/Open/, 'update meta does not says marked as open'; - unlike $update_meta->[0], qr/reopened/, 'update meta does not say reopened'; + unlike $update_meta->[0], qr/Open/, 'update meta does not say reopened'; }; subtest "check first comment with no status change has no status in meta" => sub { @@ -782,7 +772,7 @@ subtest "check first comment with no status change has no status in meta" => sub $mech->get_ok("/report/$report_id"); my $update_meta = $mech->extract_update_metas; - unlike $update_meta->[0], qr/marked as|reopened/, 'update meta does not include state change'; + unlike $update_meta->[0], qr/State changed to/, 'update meta does not include state change'; }; subtest "check comment with no status change has not status in meta" => sub { @@ -820,7 +810,7 @@ subtest "check comment with no status change has not status in meta" => sub { is $report->state, 'fixed - council', 'correct report state'; is $update->problem_state, 'fixed - council', 'correct update state'; my $update_meta = $mech->extract_update_metas; - unlike $update_meta->[1], qr/marked as/, 'update meta does not include state change'; + unlike $update_meta->[1], qr/State changed to/, 'update meta does not include state change'; $user->from_body( $body->id ); $user->update; @@ -854,9 +844,9 @@ subtest "check comment with no status change has not status in meta" => sub { is $report->state, 'investigating', 'correct report state'; is $update->problem_state, 'investigating', 'correct update state'; $update_meta = $mech->extract_update_metas; - like $update_meta->[0], qr/marked as fixed/, 'first update meta says fixed'; - unlike $update_meta->[1], qr/marked as/, 'second update meta does not include state change'; - like $update_meta->[2], qr/marked as investigating/, 'third update meta says investigating'; + like $update_meta->[0], qr/fixed/i, 'first update meta says fixed'; + unlike $update_meta->[2], qr/State changed to/, 'second update meta does not include state change'; + like $update_meta->[3], qr/investigating/i, 'third update meta says investigating'; my $dt = DateTime->now( time_zone => "local" )->add( seconds => 1 ); $comment = FixMyStreet::App->model('DB::Comment')->find_or_create( @@ -883,10 +873,10 @@ subtest "check comment with no status change has not status in meta" => sub { is $report->state, 'investigating', 'correct report state'; is $update->problem_state, undef, 'no update state'; $update_meta = $mech->extract_update_metas; - like $update_meta->[0], qr/marked as fixed/, 'first update meta says fixed'; - unlike $update_meta->[1], qr/marked as/, 'second update meta does not include state change'; - like $update_meta->[2], qr/marked as investigating/, 'third update meta says investigating'; - unlike $update_meta->[3], qr/marked as/, 'fourth update meta has no state change'; + like $update_meta->[0], qr/fixed/i, 'first update meta says fixed'; + unlike $update_meta->[2], qr/State changed to/, 'second update meta does not include state change'; + like $update_meta->[3], qr/investigating/i, 'third update meta says investigating'; + unlike $update_meta->[5], qr/State changed to/, 'fourth update meta has no state change'; }; subtest 'check meta correct for second comment marking as reopened' => sub { @@ -907,7 +897,7 @@ subtest 'check meta correct for second comment marking as reopened' => sub { $mech->get_ok( "/report/" . $report->id ); my $update_meta = $mech->extract_update_metas; - like $update_meta->[0], qr/fixed/, 'update meta says fixed'; + like $update_meta->[0], qr/fixed/i, 'update meta says fixed'; $comment = FixMyStreet::App->model('DB::Comment')->create( { @@ -925,7 +915,7 @@ subtest 'check meta correct for second comment marking as reopened' => sub { $mech->get_ok( "/report/" . $report->id ); $update_meta = $mech->extract_update_metas; - like $update_meta->[1], qr/reopened/, 'update meta says reopened'; + like $update_meta->[2], qr/Open/, 'update meta says reopened'; }; subtest "check first comment with status change but no text is displayed" => sub { @@ -953,9 +943,9 @@ subtest "check first comment with status change but no text is displayed" => sub $mech->get_ok("/report/$report_id"); my $update_meta = $mech->extract_update_metas; - like $update_meta->[0], qr/Updated by/, 'updated by meta if no text'; - unlike $update_meta->[0], qr/Test User/, 'commenter name not included'; - like $update_meta->[0], qr/investigating/, 'update meta includes state change'; + like $update_meta->[1], qr/Updated by/, 'updated by meta if no text'; + unlike $update_meta->[1], qr/Test User/, 'commenter name not included'; + like $update_meta->[0], qr/investigating/i, 'update meta includes state change'; ok $user->user_body_permissions->create({ body => $body, @@ -964,9 +954,9 @@ subtest "check first comment with status change but no text is displayed" => sub $mech->get_ok("/report/$report_id"); $update_meta = $mech->extract_update_metas; - like $update_meta->[0], qr/Updated by/, 'updated by meta if no text'; - like $update_meta->[0], qr/Test User/, 'commenter name included if user has view contribute permission'; - like $update_meta->[0], qr/investigating/, 'update meta includes state change'; + like $update_meta->[1], qr/Updated by/, 'updated by meta if no text'; + like $update_meta->[1], qr/Test User/, 'commenter name included if user has view contribute permission'; + like $update_meta->[0], qr/investigating/i, 'update meta includes state change'; }; diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index 46c2472cd..f3053c29a 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -41,9 +41,9 @@ for my $update ('in progress', 'unable to fix') { # Test Bromley special casing of 'unable to fix' $mech->get_ok( '/report/' . $report->id ); $mech->content_contains( 'marks it as in progress' ); -$mech->content_contains( 'marked as in progress' ); +$mech->content_contains( 'State changed to: In progress' ); $mech->content_contains( 'marks it as unable to fix' ); -$mech->content_contains( 'marked as no further action' ); +$mech->content_contains( 'State changed to: No further action' ); subtest 'testing special Open311 behaviour', sub { $report->set_extra_fields(); diff --git a/templates/web/base/admin/problem_row.html b/templates/web/base/admin/problem_row.html index 79461367e..446e94d66 100644 --- a/templates/web/base/admin/problem_row.html +++ b/templates/web/base/admin/problem_row.html @@ -34,8 +34,8 @@ [% loc('Created') %]: [% PROCESS format_time time=problem.created %] <br>[% loc('When sent') %]: [% PROCESS format_time time=problem.whensent %] [%- IF problem.is_visible %]<br>[% loc('Confirmed:' ) %] [% PROCESS format_time time=problem.confirmed %][% END -%] - [%- IF problem.is_fixed %]<br>[% loc('Fixed:') %] [% PROCESS format_time time=problem.lastupdate %][% END -%] - [%- IF problem.is_closed %]<br>[% loc('Closed:') %] [% PROCESS format_time time=problem.lastupdate %][% END -%] + [%- IF problem.is_fixed %]<br>[% prettify_state('fixed') %]: [% PROCESS format_time time=problem.lastupdate %][% END -%] + [%- IF problem.is_closed %]<br>[% prettify_state('closed') %]: [% PROCESS format_time time=problem.lastupdate %][% END -%] [%- IF problem.is_open %]<br>[% loc('Last update:') %] [% PROCESS format_time time=problem.lastupdate %][% END -%] </small></td> <td><a href="[% c.uri_for( 'report_edit', problem.id ) %]">[% loc('Edit') %]</a></td> diff --git a/templates/web/base/admin/report_blocks.html b/templates/web/base/admin/report_blocks.html index 933521b94..f5896b88f 100644 --- a/templates/web/base/admin/report_blocks.html +++ b/templates/web/base/admin/report_blocks.html @@ -1,13 +1,7 @@ [% SET report_blocks_included = 1; - -SET state_groups = [ - [ loc('Open'), [ 'confirmed', 'investigating', 'planned', 'in progress', 'action scheduled' ] ], - [ loc('Fixed'), [ 'fixed', 'fixed - user', 'fixed - council' ] ], - [ loc('Closed'), [ 'unable to fix', 'not responsible', 'duplicate', 'closed', 'internal referral' ] ], - [ loc('Hidden'), [ 'hidden', 'partial', 'unconfirmed' ] ] -]; +SET state_groups = c.cobrand.state_groups_admin; %] diff --git a/templates/web/base/dashboard/index.html b/templates/web/base/dashboard/index.html index 6033ef36b..e47798573 100644 --- a/templates/web/base/dashboard/index.html +++ b/templates/web/base/dashboard/index.html @@ -136,11 +136,12 @@ </select> <p>[% loc('Report state:') %] <select class="form-control" name="state"> <option value=''>[% loc('All') %]</option> - [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating', - loc('Investigating')], ['action scheduled', loc('Planned')], ['in progress', - loc('In Progress')], ['closed', loc('Closed')], ['fixed', loc('Fixed')] ] %] - <option [% 'selected ' IF state.0 == q_state %] value="[% state.0 %]">[% state.1 %]</option> - [% END %] + [% FOR group IN filter_states %] + [% FOR state IN group.1 %] + [% NEXT IF state == 'hidden' %] + <option [% 'selected ' IF state == q_state %] value="[% state %]">[% prettify_state(state, 1) %]</option> + [% END %] + [% END %] </select> <input type="submit" class="btn" value="[% loc('Look up') %]"> <a class="export_as_csv" href="[% c.req.uri_with({ export => 1 }) %]">[% loc('Export as CSV') %]</a> diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html index 3f5c5464b..9449ca55d 100644 --- a/templates/web/base/report/_item.html +++ b/templates/web/base/report/_item.html @@ -40,9 +40,9 @@ [% END %] <small> [% IF NOT no_fixed AND problem.is_fixed %] - <span class="item-list__item__state">[% loc('Fixed') %]</span> + <span class="item-list__item__state">[% prettify_state('fixed') %]</span> [% ELSIF NOT no_fixed AND problem.is_closed %] - <span class="item-list__item__state">[% loc('Closed') %]</span> + <span class="item-list__item__state">[% prettify_state('closed') %]</span> [% ELSIF (c.user.has_permission_to('report_edit_priority', problem.bodies_str_ids) OR c.user.has_permission_to('report_inspect', problem.bodies_str_ids)) AND problem.response_priority %] <span class="item-list__item__state">[% problem.response_priority.name %]</span> [% END %] diff --git a/templates/web/base/report/banner.html b/templates/web/base/report/banner.html index c80d129eb..ee73d287a 100644 --- a/templates/web/base/report/banner.html +++ b/templates/web/base/report/banner.html @@ -9,11 +9,11 @@ [% INCLUDE banner, id = 'unknown', text = loc('Unknown') %] [% END %] [% IF problem.is_fixed %] - [% INCLUDE banner, id = 'fixed', text = loc('Fixed') %] + [% INCLUDE banner, id = 'fixed', text = prettify_state('fixed') %] [% END %] [% IF problem.is_closed %] - [% INCLUDE banner, id = 'closed', text = loc('Closed') %] + [% INCLUDE banner, id = 'closed', text = prettify_state('closed') %] [% END %] [% IF problem.is_in_progress %] - [% INCLUDE banner, id = 'progress', text = loc('In progress') %] + [% INCLUDE banner, id = 'progress', text = prettify_state(problem.state) %] [% END %] diff --git a/templates/web/base/report/inspect/state_groups_select.html b/templates/web/base/report/inspect/state_groups_select.html index 2cf1a4de5..998b99739 100644 --- a/templates/web/base/report/inspect/state_groups_select.html +++ b/templates/web/base/report/inspect/state_groups_select.html @@ -1,11 +1,6 @@ [% -SET state_groups = [ - [ loc('Open'), [ 'confirmed', 'investigating', 'in progress', 'action scheduled' ] ], - [ loc('Fixed'), [ 'fixed - council' ] ], - [ loc('Closed'), [ 'unable to fix', 'not responsible', 'duplicate', 'internal referral' ] ], - [ loc('Hidden'), [ 'hidden' ] ] -]; +SET state_groups = c.cobrand.state_groups_inspect; %] [% DEFAULT current_state = problem.state %] diff --git a/templates/web/base/report/state-list.html b/templates/web/base/report/state-list.html deleted file mode 100644 index e137c81e2..000000000 --- a/templates/web/base/report/state-list.html +++ /dev/null @@ -1,21 +0,0 @@ -[% -SET state_pretty = { - 'confirmed' = loc('Open') - 'investigating' = loc('Investigating') - 'planned' = loc('Planned') - 'in progress' = loc('In progress') - 'action scheduled' = loc('Action Scheduled') - 'fixed' = loc('Fixed') - 'fixed - user' = loc('Fixed - User') - 'fixed - council' = loc('Fixed - Council') - 'unable to fix' = loc('No further action') - 'not responsible' = loc('Not Responsible') - 'duplicate' = loc('Duplicate') - 'closed' = loc('Closed') - 'internal referral' = loc('Internal referral') - 'hidden' = loc('Hidden') - 'partial' = loc('Partial') - 'unconfirmed' = loc('Unconfirmed') -}; -state_pretty.$state -~%] diff --git a/templates/web/base/report/update.html b/templates/web/base/report/update.html index 1f1438bfc..85624669a 100644 --- a/templates/web/base/report/update.html +++ b/templates/web/base/report/update.html @@ -43,6 +43,12 @@ </div> [% END %] + [% SET update_state = update.problem_state_display(c) %] + [% IF update_state AND update_state != global.last_state AND NOT (global.last_state == "" AND update.problem_state == 'confirmed') %] + <p class="meta-2">[% loc('State changed to:') %] [% update_state %]</p> + [%- global.last_state = update_state %] + [% END %] + <p class="meta-2"> [% INCLUDE meta_line %] [% IF c.user_exists AND c.user.id == update.user_id AND !update.anonymous %] diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html index ef7c7ad78..329e481ae 100644 --- a/templates/web/base/reports/_list-filters.html +++ b/templates/web/base/reports/_list-filters.html @@ -1,6 +1,6 @@ [% select_status = BLOCK %] <select class="form-control js-multiple" name="status" id="statuses" multiple - data-all="[% loc('All reports') %]" data-all-options='["open","closed","fixed"]' + data-all="[% loc('All') %]" data-all-options='["open","closed","fixed"]' [%~ IF c.cobrand.on_map_default_status == 'open' %] data-none="[% loc('Unfixed reports') %]" [%~ END ~%] @@ -10,19 +10,16 @@ <option value="unshortlisted"[% ' selected' IF filter_status.unshortlisted %]>[% loc('Unshortlisted') %]</option> [% END %] [% IF c.user_exists AND c.user.is_superuser OR c.user.belongs_to_body(body.id) %] - <option value="confirmed"[% ' selected' IF filter_status.confirmed %]>[% loc('Open') %]</option> - <option value="investigating"[% ' selected' IF filter_status.investigating %]>[% loc('Investigating') %]</option> - <option value="in progress"[% ' selected' IF filter_status.in_progress %]>[% loc('In progress') %]</option> - <option value="action scheduled"[% ' selected' IF filter_status.action_scheduled %]>[% loc('Action scheduled') %]</option> - <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% loc('Fixed reports') %]</option> - <option value="unable to fix"[% ' selected' IF filter_status.unable_to_fix %]>[% loc('No further action') %]</option> - <option value="not responsible"[% ' selected' IF filter_status.not_responsible %]>[% loc('Not responsible') %]</option> - <option value="internal referral"[% ' selected' IF filter_status.internal_referral %]>[% loc('Internal referral') %]</option> - <option value="duplicate"[% ' selected' IF filter_status.duplicate %]>[% loc('Duplicate') %]</option> + [% FOR group IN filter_states %] + [% FOR state IN group.1 %] + [% NEXT IF state == 'hidden' %] + <option value="[% state %]"[% ' selected' IF filter_status.$state %]>[% prettify_state(state, 1) %]</option> + [% END %] + [% END %] [% ELSE %] - <option value="open"[% ' selected' IF filter_status.open %]>[% loc('Unfixed reports') %]</option> - <option value="closed"[% ' selected' IF filter_status.closed %]>[% loc('Closed reports') %]</option> - <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% loc('Fixed reports') %]</option> + <option value="open"[% ' selected' IF filter_status.open %]>[% prettify_state('confirmed') %]</option> + <option value="closed"[% ' selected' IF filter_status.closed %]>[% prettify_state('closed') %]</option> + <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% prettify_state('fixed') %]</option> [% END %] </select> [% END %] @@ -46,7 +43,7 @@ [% END %] <p class="report-list-filters"> - [% tprintf(loc('<label for="statuses">Show</label> %s <label for="filter_categories">about</label> %s', "The first %s is a dropdown of all/fixed/etc, the second is a dropdown of categories"), select_status, select_category) %] + [% tprintf(loc('<label for="statuses">Show</label> %s reports <label for="filter_categories">about</label> %s', "The first %s is a dropdown of all/fixed/etc, the second is a dropdown of categories"), select_status, select_category) %] <input type="submit" name="filter_update" value="[% loc('Go') %]"> </p> diff --git a/templates/web/oxfordshire/report/inspect/state_groups_select.html b/templates/web/oxfordshire/report/inspect/state_groups_select.html deleted file mode 100644 index d36fb0191..000000000 --- a/templates/web/oxfordshire/report/inspect/state_groups_select.html +++ /dev/null @@ -1,12 +0,0 @@ -[% - -SET state_groups = [ - [ loc('New'), [ 'confirmed', 'investigating' ] ], - [ loc('Scheduled'), [ 'action scheduled' ] ], - [ loc('Fixed'), [ 'fixed - council' ] ], - [ loc('Closed'), [ 'not responsible', 'duplicate', 'unable to fix' ] ] -]; - -%] -[% DEFAULT current_state = problem.state %] -[% INCLUDE 'report/_state_select_field.html' single_fixed=1 %] |