aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-08-29 15:15:10 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-29 15:15:10 +0100
commit759b5ef970546c0a70fb4f8d051b1f6dd54e4d2d (patch)
tree2f76a073e1c07df40e8cec71cafef02f5d54c184 /perllib
parent05c6a4b980b07a7c15b6b9727f6315d326e233a0 (diff)
parentb43dbace0f747897640920e4cf9adb55b84bc2c8 (diff)
Merge branch 'move-report-states-to-database-part-1'
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm2
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm5
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm52
-rw-r--r--perllib/FixMyStreet/Test.pm2
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm2
8 files changed, 17 insertions, 58 deletions
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