diff options
author | Struan Donald <struan@exo.org.uk> | 2012-10-01 12:31:51 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-10-01 17:38:26 +0100 |
commit | 741abb421c66bdf91a60a988d7250feb59c6ca45 (patch) | |
tree | c0b9bdf04380158dd9375471e583eabb7eb3ea6b | |
parent | be97fe44d9954ce3c84d98030f2ebc6ae84a5a61 (diff) |
Don't have the list of states harcoded in more than one place
Also sort out some warnings that were being issues during tests
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 44 |
2 files changed, 45 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 298c75352..1efa2827b 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -59,11 +59,9 @@ sub index : Path : Args(0) { %prob_counts = map { $_ => $prob_counts{$_} || 0 } - ('confirmed', 'investigating', 'in progress', 'closed', 'fixed - council', - 'fixed - user', 'fixed', 'unconfirmed', 'hidden', - 'partial', 'planned'); + ( FixMyStreet::DB::Result::Problem->all_states() ); $c->stash->{problems} = \%prob_counts; - $c->stash->{total_problems_live} += $prob_counts{$_} + $c->stash->{total_problems_live} += $prob_counts{$_} ? $prob_counts{$_} : 0 for ( FixMyStreet::DB::Result::Problem->visible_states() ); $c->stash->{total_problems_users} = $c->cobrand->problems->unique_users; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index a72a8fd23..27613c1c8 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -243,7 +243,7 @@ sub closed_states { @states = FixMyStreet::DB::Problem::visible_states(); -Get a list or states that should be visible on the site. If called in +Get a list of states that should be visible on the site. If called in array context then returns an array of names, otherwise returns a HASHREF. @@ -268,8 +268,50 @@ sub visible_states { return wantarray ? keys %{$states} : $states; } +=head2 + + @states = FixMyStreet::DB::Problem::all_states(); + +Get a list of all states that a problem can have. If called in +array context then returns an array of names, otherwise returns a +HASHREF. + +=cut + +sub all_states { + my $states = { + 'hidden' => 1, + 'partial' => 1, + 'unconfirmed' => 1, + 'confirmed' => 1, + 'planned' => 1, + 'investigating' => 1, + 'in progress' => 1, + 'action scheduled' => 1, + 'fixed' => 1, + 'fixed - council' => 1, + 'fixed - user' => 1, + 'unable to fix' => 1, + 'not councils responsibility' => 1, + 'duplicate' => 1, + 'closed' => 1, + }; + + return wantarray ? keys %{$states} : $states; +} + +=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, 'planned' => 1, 'investigating' => 1, 'in progress' => 1, |