aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-01-16 11:47:20 +0000
committerStruan Donald <struan@exo.org.uk>2013-01-16 11:47:20 +0000
commit682db36dca4db6c0682deeb4fb704e8cf222e38c (patch)
tree5811b7e2288f48b0bc814f7f505e19cb705294d9 /perllib/FixMyStreet/App
parent257b658e49da3665a426f1c98d9760b0d53b8d3d (diff)
parent3c4c0ec2f55d82502169d2313745920850efdc99 (diff)
Merge branch 'bromley-new-statuses'
Conflicts: bin/send-comments conf/crontab.ugly db/schema.sql perllib/FixMyStreet/App/Controller/Admin.pm perllib/FixMyStreet/DB/Result/Open311conf.pm perllib/FixMyStreet/DB/ResultSet/Problem.pm perllib/Open311.pm t/app/controller/report_updates.t t/open311.t templates/web/default/report/display.html templates/web/default/report/updates.html templates/web/fixmystreet/report/display.html
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm10
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm18
3 files changed, 28 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 7a2790b31..e14c7dc66 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -65,11 +65,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;
@@ -351,7 +349,7 @@ sub update_contacts : Private {
} elsif ( $posted eq 'open311' ) {
$c->forward('check_token');
- my %params = map { $_ => $c->req->param($_) || '' } qw/open311_id endpoint jurisdiction api_key area_id send_method send_comments suppress_alerts comment_user_id devolved/;
+ my %params = map { $_ => $c->req->param($_) || '' } qw/open311_id endpoint jurisdiction api_key area_id send_method send_comments suppress_alerts extended_statuses comment_user_id devolved/;
if ( $params{open311_id} ) {
my $conf = $c->model('DB::Open311Conf')->find( { id => $params{open311_id} } );
@@ -364,6 +362,7 @@ sub update_contacts : Private {
$conf->suppress_alerts( $params{suppress_alerts} || 0);
$conf->comment_user_id( $params{comment_user_id} || undef );
$conf->can_be_devolved( $params{devolved} || 0 );
+ $conf->send_extended_statuses( $params{extended_statuses} || 0 );
$conf->update();
@@ -379,6 +378,7 @@ sub update_contacts : Private {
$conf->suppress_alerts( $params{suppress_alerts} || 0);
$conf->comment_user_id( $params{comment_user_id} || undef );
$conf->can_be_devolved( $params{devolved} || 0 );
+ $conf->send_extended_statuses( $params{extended_statuses} || 0 );
$conf->insert();
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index a5ba8ff07..17fd8b867 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -138,6 +138,8 @@ sub index : Path : Args(0) {
$prob_where->{state} = [ FixMyStreet::DB::Result::Problem->fixed_states() ];
} elsif ( $c->stash->{q_state} ) {
$prob_where->{state} = $c->stash->{q_state};
+ $prob_where->{state} = { IN => [ 'planned', 'action scheduled' ] }
+ if $prob_where->{state} eq 'action scheduled';
}
my $params = {
%$prob_where,
@@ -181,11 +183,13 @@ sub updates_search : Private {
map { $_ => $counts{$_} || 0 }
('confirmed', 'investigating', 'in progress', 'closed', 'fixed - council',
'fixed - user', 'fixed', 'unconfirmed', 'hidden',
- 'partial', 'planned');
+ 'partial', 'action scheduled', 'planned');
+
+ $counts{'action scheduled'} += $counts{planned} || 0;
for my $vars (
[ 'time_to_fix', 'fixed - council' ],
- [ 'time_to_mark', 'in progress', 'planned', 'investigating', 'closed' ],
+ [ 'time_to_mark', 'in progress', 'action scheduled', 'investigating', 'closed' ],
) {
my $col = shift @$vars;
my $substmt = "select min(id) from comment where me.problem_id=comment.problem_id and problem_state in ('"
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index da4cc33ca..5e0d9f388 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -203,8 +203,23 @@ sub process_update : Private {
$params{state} = 'fixed - council'
if $params{state} eq 'fixed' && $c->user && $c->user->belongs_to_council( $update->problem->council );
$update->problem_state( $params{state} );
+ } else {
+ # we do this so we have a record of the state of the problem at this point
+ # for use when sending updates to external parties
+ if ( $update->mark_fixed ) {
+ $update->problem_state( 'fixed - user' );
+ } elsif ( $update->mark_open ) {
+ $update->problem_state( 'confirmed' );
+ # if there is not state param and neither of the above conditions apply
+ # then we are not changing the state of the problem so can use the current
+ # problem state
+ } else {
+ my $problem = $c->stash->{problem} || $update->problem;
+ $update->problem_state( $problem->state );
+ }
}
+
my @extra; # Next function fills this, but we don't need it here.
# This is just so that the error checkign for these extra fields runs.
# TODO Use extra here as it is used on reports.
@@ -249,7 +264,8 @@ sub check_for_errors : Private {
$error = 1 unless $c->user && $c->user->belongs_to_council( $c->stash->{update}->problem->council );
my $state = $c->req->param('state');
- $error = 1 unless ( grep { $state eq $_ } ( qw/confirmed closed fixed investigating planned/, 'in progress', 'fixed', 'fixed - user', 'fixed - council' ) );
+ $state = 'fixed - council' if $state eq 'fixed';
+ $error = 1 unless ( grep { $state eq $_ } ( FixMyStreet::DB::Result::Problem->council_states() ) );
if ( $error ) {
$c->stash->{errors} ||= [];