diff options
26 files changed, 30 insertions, 86 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2464bd8d6..fdbb6c638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Update map size if an extra column has appeared. - Improve performance of various pages. #1799 - Duplicate list not loading when phone number present. #1803 + - Don't list multiple fixed states all as Fixed in dropdown. #1824 - Development improvements: - `switch-site` script to automate switching config.yml files. #1741 - `make_css --watch` can run custom script after each compilation. diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 2365118ea..b7bbc8a0a 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -219,11 +219,7 @@ sub setup_request { mySociety::MaPit::configure( "http://$host/fakemapit/" ); } - # XXX Put in cobrand / do properly - if ($c->cobrand->moniker eq 'zurich') { - FixMyStreet::DB::Result::Problem->visible_states_add('unconfirmed'); - FixMyStreet::DB::Result::Problem->visible_states_remove('investigating'); - } + $c->cobrand->call_hook('setup_states'); if (FixMyStreet->test_mode) { # Is there a better way of altering $c->config that may have diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index cd1246134..f1508f0b1 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -523,7 +523,7 @@ sub fetch_languages : Private { my ( $self, $c ) = @_; my $lang_map = {}; - foreach my $lang (sort @{$c->cobrand->languages}) { + foreach my $lang (@{$c->cobrand->languages}) { my ($id, $name, $code) = split(',', $lang); $lang_map->{$id} = { name => $name, code => $code }; } diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 068f393f2..033f5c017 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -351,7 +351,7 @@ sub check_for_errors : Private { if ( $state && $state ne $c->stash->{update}->problem->state ) { my $error = 0; $error = 1 unless $c->user && $c->user->belongs_to_body( $c->stash->{update}->problem->bodies_str ); - $error = 1 unless grep { $state eq $_ } FixMyStreet::DB::Result::Problem->council_states(); + $error = 1 unless grep { $state eq $_ } FixMyStreet::DB::Result::Problem->visible_states(); if ( $error ) { $c->stash->{errors} ||= []; push @{ $c->stash->{errors} }, _('There was a problem with your update. Please try again.'); diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index fe200a8fc..93c459e26 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -169,12 +169,12 @@ sub decode { } sub prettify_state { - my ($self, $c, $text) = @_; + 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/ - .*//; + $var =~ s/ - .*// if $single_fixed; return $var; } diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index c56f595ca..de4a5262a 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -54,6 +54,11 @@ you already have, and the countres set so that they shouldn't in future. =cut +sub setup_states { + FixMyStreet::DB::Result::Problem->visible_states_add('unconfirmed'); + FixMyStreet::DB::Result::Problem->visible_states_remove('investigating'); +} + sub shorten_recency_if_new_greater_than_fixed { return 0; } diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 0d1b396a9..a74a04828 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -323,75 +323,31 @@ my $hidden_states = { 'unconfirmed' => 1, }; -my $visible_states = { - map { - $hidden_states->{$_} ? () : ($_ => 1) - } all_states() -}; - ## e.g.: - # 'confirmed' => 1, - # 'investigating' => 1, - # 'in progress' => 1, - # 'planned' => 1, - # 'action scheduled' => 1, - # 'fixed' => 1, - # 'fixed - council' => 1, - # 'fixed - user' => 1, - # 'unable to fix' => 1, - # 'not responsible' => 1, - # 'duplicate' => 1, - # 'closed' => 1, - # 'internal referral' => 1, - sub hidden_states { return wantarray ? keys %{$hidden_states} : $hidden_states; } sub visible_states { - return wantarray ? keys %{$visible_states} : $visible_states; + my %visible_states = map { + $hidden_states->{$_} ? () : ($_ => 1) + } all_states(); + return wantarray ? keys %visible_states : \%visible_states; } sub visible_states_add { my ($self, @states) = @_; for my $state (@states) { delete $hidden_states->{$state}; - $visible_states->{$state} = 1; } } sub visible_states_remove { my ($self, @states) = @_; for my $state (@states) { - delete $visible_states->{$state}; $hidden_states->{$state} = 1; } } -=head2 - - @states = FixMyStreet::DB::Problem::council_states(); - -Get a list of states that are availble to council users. If called in -array context then returns an array of names, otherwise returns a -HASHREF. - -=cut -sub council_states { - my $states = { - 'confirmed' => 1, - 'investigating' => 1, - 'action scheduled' => 1, - 'in progress' => 1, - 'fixed - council' => 1, - 'unable to fix' => 1, - 'not responsible' => 1, - 'duplicate' => 1, - 'internal referral' => 1, - }; - - return wantarray ? keys %{$states} : $states; -} - my $stz = sub { my ( $orig, $self ) = ( shift, shift ); my $s = $self->$orig(@_); diff --git a/perllib/FixMyStreet/Test.pm b/perllib/FixMyStreet/Test.pm index 6b6bc02bc..572ae0a44 100644 --- a/perllib/FixMyStreet/Test.pm +++ b/perllib/FixMyStreet/Test.pm @@ -6,6 +6,7 @@ use strict; use warnings FATAL => 'all'; use utf8; use Test::More; +use mySociety::Locale; use FixMyStreet::DB; my $db = FixMyStreet::DB->schema->storage; @@ -21,6 +22,7 @@ sub import { BEGIN { use FixMyStreet; FixMyStreet->test_mode(1); + mySociety::Locale::gettext_domain('FixMyStreet', 1); } END { diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 6ba53b7af..db2a452da 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -142,7 +142,7 @@ sub update_comments { # don't update state unless it's an allowed state and it's # actually changing the state of the problem - if ( FixMyStreet::DB::Result::Problem->council_states()->{$state} && $p->state ne $state && + if ( FixMyStreet::DB::Result::Problem->visible_states()->{$state} && $p->state ne $state && # For Oxfordshire, don't allow changes back to Open from other open states !( $body->areas->{$AREA_ID_OXFORDSHIRE} && $state eq 'confirmed' && $p->is_open ) && # Don't let it change between the (same in the front end) fixed states diff --git a/t/Mock/MapItZurich.pm b/t/Mock/MapItZurich.pm index f7bcda31d..f7fd61a32 100644 --- a/t/Mock/MapItZurich.pm +++ b/t/Mock/MapItZurich.pm @@ -3,8 +3,6 @@ package t::Mock::MapItZurich; use JSON::MaybeXS; use Web::Simple; -use mySociety::Locale; - has json => ( is => 'lazy', default => sub { diff --git a/t/app/controller/admin_reportextrafields.t b/t/app/controller/admin_reportextrafields.t index 4c706687a..fb06665f4 100644 --- a/t/app/controller/admin_reportextrafields.t +++ b/t/app/controller/admin_reportextrafields.t @@ -31,6 +31,10 @@ package main; use FixMyStreet::TestMech; +# disable info logs for this test run +FixMyStreet::App->log->disable('info'); +END { FixMyStreet::App->log->enable('info'); } + my $mech = FixMyStreet::TestMech->new; my $user = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t index eab4ec614..c978b5ccf 100644 --- a/t/app/model/alert_type.t +++ b/t/app/model/alert_type.t @@ -1,7 +1,5 @@ use FixMyStreet::TestMech; -mySociety::Locale::gettext_domain( 'FixMyStreet' ); - my $mech = FixMyStreet::TestMech->new(); # this is the easiest way to make sure we're not going diff --git a/t/app/model/problem.t b/t/app/model/problem.t index b0719d6a6..efc9057da 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -2,11 +2,8 @@ use FixMyStreet::TestMech; use FixMyStreet; use FixMyStreet::App; use FixMyStreet::DB; -use mySociety::Locale; use Sub::Override; -mySociety::Locale::gettext_domain('FixMyStreet'); - my $problem_rs = FixMyStreet::DB->resultset('Problem'); my $problem = $problem_rs->new( diff --git a/t/app/script/archive_old_enquiries.t b/t/app/script/archive_old_enquiries.t index fb1949d9f..e1adeec85 100644 --- a/t/app/script/archive_old_enquiries.t +++ b/t/app/script/archive_old_enquiries.t @@ -1,8 +1,6 @@ use FixMyStreet::TestMech; use FixMyStreet::Script::ArchiveOldEnquiries; -mySociety::Locale::gettext_domain( 'FixMyStreet' ); - my $mech = FixMyStreet::TestMech->new(); $mech->clear_emails_ok; diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t index 718b0a495..6b292725b 100644 --- a/t/app/sendreport/email.t +++ b/t/app/sendreport/email.t @@ -2,7 +2,6 @@ use FixMyStreet; use FixMyStreet::DB; use FixMyStreet::SendReport::Email; use FixMyStreet::TestMech; -use mySociety::Locale; ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t index 684395bac..73bdd14f7 100644 --- a/t/app/sendreport/inspection_required.t +++ b/t/app/sendreport/inspection_required.t @@ -2,7 +2,6 @@ use FixMyStreet; use FixMyStreet::DB; use FixMyStreet::TestMech; use FixMyStreet::SendReport::Email; -use mySociety::Locale; ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); diff --git a/t/cobrand/closest.t b/t/cobrand/closest.t index 088349f39..36fe78a01 100644 --- a/t/cobrand/closest.t +++ b/t/cobrand/closest.t @@ -1,6 +1,5 @@ use t::Mock::Bing; -use mySociety::Locale; use FixMyStreet::DB; use FixMyStreet::TestMech; @@ -8,8 +7,6 @@ my $mech = FixMyStreet::TestMech->new; use_ok 'FixMyStreet::Cobrand'; -mySociety::Locale::gettext_domain( 'FixMyStreet' ); - my $c = FixMyStreet::Cobrand::UK->new(); my $user = diff --git a/t/cobrand/get_body_sender.t b/t/cobrand/get_body_sender.t index a53472128..06ffb42a5 100644 --- a/t/cobrand/get_body_sender.t +++ b/t/cobrand/get_body_sender.t @@ -1,12 +1,9 @@ use FixMyStreet::Test; -use mySociety::Locale; use FixMyStreet::DB; use_ok 'FixMyStreet::Cobrand'; -mySociety::Locale::gettext_domain( 'FixMyStreet' ); - my $c = FixMyStreet::Cobrand::FixMyStreet->new(); FixMyStreet::DB->resultset('BodyArea')->search( { body_id => 1000 } )->delete; diff --git a/t/map/tilma/original.t b/t/map/tilma/original.t index 4766e9363..b29155bee 100644 --- a/t/map/tilma/original.t +++ b/t/map/tilma/original.t @@ -2,14 +2,11 @@ use FixMyStreet::DB; use FixMyStreet::Map; use FixMyStreet::TestMech; use DateTime; -use mySociety::Locale; use Catalyst::Test 'FixMyStreet::App'; my $mech = FixMyStreet::TestMech->new; -mySociety::Locale::gettext_domain('FixMyStreet'); - FixMyStreet::Map::set_map_class(); my $c = ctx_request('http://fixmystreet.com/test?bbox=-7.6,49.7,-7.5,49.8'); diff --git a/templates/web/base/admin/_translations.html b/templates/web/base/admin/_translations.html index d2e0ba322..d8f7d52fb 100644 --- a/templates/web/base/admin/_translations.html +++ b/templates/web/base/admin/_translations.html @@ -6,7 +6,7 @@ <th>[% loc('Language') %]</th> <th>[% loc('Translation') %]</th> </tr> - [% FOREACH language IN languages.keys %] + [% FOREACH language IN languages.keys.sort %] <tr> <td> <label for="translation_[% language %]">[% languages.$language.name %] ([% language %])</label> diff --git a/templates/web/base/admin/problem_row.html b/templates/web/base/admin/problem_row.html index def6ce60f..79461367e 100644 --- a/templates/web/base/admin/problem_row.html +++ b/templates/web/base/admin/problem_row.html @@ -30,7 +30,7 @@ [%- END -%] <br>[% problem.cobrand %]<br>[% problem.cobrand_data | html %] </td> - <td>[% prettify_state(problem.state) %]<br><small> + <td>[% prettify_state(problem.state, 1) %]<br><small> [% 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 -%] diff --git a/templates/web/base/admin/state_groups_select.html b/templates/web/base/admin/state_groups_select.html index 9a70cd2c9..87674c47d 100644 --- a/templates/web/base/admin/state_groups_select.html +++ b/templates/web/base/admin/state_groups_select.html @@ -1,3 +1,3 @@ [% PROCESS 'admin/report_blocks.html'; # For state_groups %] [% DEFAULT current_state = problem.state %] -[% INCLUDE 'report/_state_select_field.html' %] +[% INCLUDE 'report/_state_select_field.html' single_fixed=0 %] diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html index 153fbf58e..3f5c5464b 100644 --- a/templates/web/base/report/_item.html +++ b/templates/web/base/report/_item.html @@ -94,7 +94,7 @@ </div> <div> <h4>[% loc('State') %]</h4> - <p>[% prettify_state(problem.state) %]</p> + <p>[% prettify_state(problem.state, 1) %]</p> </div> <div> <h4>[% loc('Priority') %]</h4> diff --git a/templates/web/base/report/_state_select_field.html b/templates/web/base/report/_state_select_field.html index c580c897d..0f6d8faf6 100644 --- a/templates/web/base/report/_state_select_field.html +++ b/templates/web/base/report/_state_select_field.html @@ -9,12 +9,12 @@ [% END ~%] [% END ~%] [% IF NOT found ~%] - <option selected value="[% current_state %]">[% prettify_state(current_state) %]</option> + <option selected value="[% current_state %]">[% prettify_state(current_state, single_fixed) %]</option> [% END ~%] [% FOREACH group IN state_groups %] <optgroup label="[% group.0 %]"> [% FOREACH state IN group.1 %] - <option [% 'selected ' IF state == current_state %]value="[% state %]">[% prettify_state(state) %]</option> + <option [% 'selected ' IF state == current_state %]value="[% state %]">[% prettify_state(state, single_fixed) %]</option> [% END %] </optgroup> [% END %] diff --git a/templates/web/base/report/inspect/state_groups_select.html b/templates/web/base/report/inspect/state_groups_select.html index af41c6770..2cf1a4de5 100644 --- a/templates/web/base/report/inspect/state_groups_select.html +++ b/templates/web/base/report/inspect/state_groups_select.html @@ -9,4 +9,4 @@ SET state_groups = [ %] [% DEFAULT current_state = problem.state %] -[% INCLUDE 'report/_state_select_field.html' %] +[% INCLUDE 'report/_state_select_field.html' single_fixed=1 %] diff --git a/templates/web/oxfordshire/report/inspect/state_groups_select.html b/templates/web/oxfordshire/report/inspect/state_groups_select.html index a5fce525c..d36fb0191 100644 --- a/templates/web/oxfordshire/report/inspect/state_groups_select.html +++ b/templates/web/oxfordshire/report/inspect/state_groups_select.html @@ -9,4 +9,4 @@ SET state_groups = [ %] [% DEFAULT current_state = problem.state %] -[% INCLUDE 'report/_state_select_field.html' %] +[% INCLUDE 'report/_state_select_field.html' single_fixed=1 %] |