diff options
author | Struan Donald <struan@exo.org.uk> | 2013-01-16 11:47:20 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-01-16 11:47:20 +0000 |
commit | 682db36dca4db6c0682deeb4fb704e8cf222e38c (patch) | |
tree | 5811b7e2288f48b0bc814f7f505e19cb705294d9 /perllib/FixMyStreet | |
parent | 257b658e49da3665a426f1c98d9760b0d53b8d3d (diff) | |
parent | 3c4c0ec2f55d82502169d2313745920850efdc99 (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')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 18 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Open311conf.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 96 |
6 files changed, 121 insertions, 23 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} ||= []; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 8c9fea282..b551be9ef 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -146,6 +146,11 @@ sub check_for_errors { $errors{update} = _('Please enter a message') unless $self->text =~ m/\S/; + if ( $self->text && $self->problem && $self->problem->council + && $self->problem->council eq '2482' && length($self->text) > 2000 ) { + $errors{update} = _('Updates are limited to 2000 characters in length. Please shorten your update'); + } + return \%errors; } @@ -186,6 +191,10 @@ sub meta_problem_state { my $state = $self->problem_state; $state =~ s/ -.*$//; + $state = _("not the council's responsibility") + if $state eq 'not responsible'; + $state = _('duplicate report') if $state eq 'duplicate'; + return $state; } diff --git a/perllib/FixMyStreet/DB/Result/Open311conf.pm b/perllib/FixMyStreet/DB/Result/Open311conf.pm index 8051e27de..f01a20dec 100644 --- a/perllib/FixMyStreet/DB/Result/Open311conf.pm +++ b/perllib/FixMyStreet/DB/Result/Open311conf.pm @@ -36,6 +36,8 @@ __PACKAGE__->add_columns( { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "can_be_devolved", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "send_extended_statuses", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->add_unique_constraint("open311conf_area_id_key", ["area_id"]); @@ -55,6 +57,5 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-08-29 14:04:20 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Yoult8K/ldH6DMAKURtr3Q - # You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index dd09ad3c2..b1f59e78a 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -196,10 +196,11 @@ HASHREF. sub open_states { my $states = { - 'confirmed' => 1, - 'investigating' => 1, - 'planned' => 1, - 'in progress' => 1, + 'confirmed' => 1, + 'investigating' => 1, + 'in progress' => 1, + 'planned' => 1, + 'action scheduled' => 1, }; return wantarray ? keys %{$states} : $states; @@ -237,7 +238,10 @@ HASHREF. sub closed_states { my $states = { - 'closed' => 1, + 'closed' => 1, + 'unable to fix' => 1, + 'not responsible' => 1, + 'duplicate' => 1, }; return wantarray ? keys %{$states} : $states; @@ -248,7 +252,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. @@ -256,14 +260,73 @@ HASHREF. sub visible_states { my $states = { - 'confirmed' => 1, - 'planned' => 1, - 'investigating' => 1, - 'in progress' => 1, - 'fixed' => 1, - 'fixed - council' => 1, - 'fixed - user' => 1, - 'closed' => 1, + '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, + }; + + 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, + 'investigating' => 1, + 'in progress' => 1, + 'action scheduled' => 1, + 'fixed' => 1, + 'fixed - council' => 1, + 'fixed - user' => 1, + 'unable to fix' => 1, + 'not responsible' => 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, + 'investigating' => 1, + 'action scheduled' => 1, + 'in progress' => 1, + 'fixed - council' => 1, + 'unable to fix' => 1, + 'not responsible' => 1, + 'duplicate' => 1, }; return wantarray ? keys %{$states} : $states; @@ -364,6 +427,11 @@ sub check_for_errors { $self->category(undef); } + if ( $self->council && $self->detail && + $self->council eq '2482' && length($self->detail) > 2000 ) { + $errors{detail} = _('Reports are limited to 2000 characters in length. Please shorten your report'); + } + return \%errors; } |