aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm10
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/JSON.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm2
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm15
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm11
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm8
7 files changed, 36 insertions, 20 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index abc454600..ae4154e98 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -56,10 +56,12 @@ sub index : Path : Args(0) {
%prob_counts =
map { $_ => $prob_counts{$_} || 0 }
- qw(confirmed fixed unconfirmed hidden partial);
+ ('confirmed', 'investigating', 'in progress', 'closed', 'fixed - council',
+ 'fixed - user', 'fixed', 'unconfirmed', 'hidden',
+ 'partial', 'planned');
$c->stash->{problems} = \%prob_counts;
- $c->stash->{total_problems_live} =
- $prob_counts{confirmed} + $prob_counts{fixed};
+ $c->stash->{total_problems_live} += $prob_counts{$_}
+ for ( FixMyStreet::DB::Result::Problem->visible_states() );
my $comments = $c->model('DB::Comment')->summary_count( $site_restriction );
@@ -740,7 +742,7 @@ sub update_edit : Path('update_edit') : Args(1) {
# If we're hiding an update, see if it marked as fixed and unfix if so
if ( $new_state eq 'hidden' && $update->mark_fixed ) {
- if ( $update->problem->state eq 'fixed' ) {
+ if ( $update->problem->is_fixed ) {
$update->problem->state('confirmed');
$update->problem->update;
}
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index a49d796fc..ec1fde4e4 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -189,7 +189,7 @@ sub display_location : Private {
{
latitude => $p->latitude,
longitude => $p->longitude,
- colour => $p->state eq 'fixed' ? 'green' : 'red',
+ colour => $p->is_fixed ? 'green' : 'red',
id => $p->id,
title => $p->title,
}
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm
index 3a3010911..d9baeaaf8 100644
--- a/perllib/FixMyStreet/App/Controller/JSON.pm
+++ b/perllib/FixMyStreet/App/Controller/JSON.pm
@@ -70,12 +70,12 @@ sub problems : Local {
}
# query the database
- my ( $state, $date_col );
+ my ( @state, $date_col );
if ( $type eq 'new_problems' ) {
- $state = 'confirmed';
+ @state = FixMyStreet::DB::Result::Problem->open_states();
$date_col = 'created';
} elsif ( $type eq 'fixed_problems' ) {
- $state = 'fixed';
+ @state = FixMyStreet::DB::Result::Problem->fixed_states();
$date_col = 'lastupdate';
}
@@ -85,7 +85,7 @@ sub problems : Local {
'>=' => $start_dt,
'<=' => $end_dt + $one_day,
},
- state => $state,
+ state => [ @state ],
}, {
order_by => { -asc => 'confirmed' },
columns => [
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index 17862aa0a..b4fa3a457 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -48,7 +48,7 @@ sub index :Path :Args(0) {
$c->detach( 'no_photo' ) if $id =~ /\D/;
@photo = $c->cobrand->problems->search( {
id => $id,
- state => [ 'confirmed', 'fixed', 'partial' ],
+ state => [ FixMyStreet::DB::Result::Problem->visible_states(), 'partial' ],
photo => { '!=', undef },
} );
}
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 19d057958..ad3827de9 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -48,7 +48,7 @@ sub load_questionnaire : Private {
$c->detach;
}
- unless ( $questionnaire->problem->state eq 'confirmed' || $questionnaire->problem->state eq 'fixed' ) {
+ unless ( $questionnaire->problem->is_visible ) {
$c->detach('missing_problem');
}
@@ -128,8 +128,8 @@ sub submit_creator_fixed : Private {
my $questionnaire = $c->model( 'DB::Questionnaire' )->find_or_new(
{
problem_id => $c->stash->{problem},
- old_state => 'confirmed',
- new_state => 'fixed',
+ old_state => [ FixMyStreet::DB::Result::Problem->open_states() ],
+ new_state => 'fixed - user',
}
);
@@ -156,8 +156,10 @@ sub submit_standard : Private {
my $problem = $c->stash->{problem};
my $old_state = $problem->state;
my $new_state = '';
- $new_state = 'fixed' if $c->stash->{been_fixed} eq 'Yes' && $old_state eq 'confirmed';
- $new_state = 'confirmed' if $c->stash->{been_fixed} eq 'No' && $old_state eq 'fixed';
+ $new_state = 'fixed - user' if $c->stash->{been_fixed} eq 'Yes' &&
+ FixMyStreet::DB::Result::Problem->open_states()->{$old_state};
+ $new_state = 'confirmed' if $c->stash->{been_fixed} eq 'No' &&
+ FixMyStreet::DB::Result::Problem->fixed_states()->{$old_state};
# Record state change, if there was one
if ( $new_state ) {
@@ -166,7 +168,8 @@ sub submit_standard : Private {
}
# If it's not fixed and they say it's still not been fixed, record time update
- if ( $c->stash->{been_fixed} eq 'No' && $old_state eq 'confirmed' ) {
+ if ( $c->stash->{been_fixed} eq 'No' &&
+ FixMyStreet::DB::Result::Problem->open_states($old_state) ) {
$problem->lastupdate( \'ms_current_timestamp()' );
}
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 86c84f14c..354690949 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -52,7 +52,7 @@ sub update_problem : Private {
my $problem = $c->stash->{problem} || $update->problem;
if ( $update->mark_fixed ) {
- $problem->state('fixed');
+ $problem->state('fixed - user');
if ( $update->user->id == $problem->user->id ) {
$problem->send_questionnaire(0);
@@ -169,6 +169,15 @@ return false.
sub check_for_errors : Private {
my ( $self, $c ) = @_;
+ # they have to be an authority user to update the state
+ if ( $c->req->param('state') ) {
+ unless ( $c->user && $c->user->from_authority ) {
+ $c->stash->{errors} ||= [];
+ push @{ $c->stash->{errors} }, _('There was a problem with your update. Please try again.');
+ return;
+ }
+ }
+
# let the model check for errors
my %field_errors = (
%{ $c->stash->{update}->user->check_for_errors },
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index a3aeb8505..fc8c4cd0e 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -259,7 +259,7 @@ sub load_and_group_problems : Private {
my ( $self, $c ) = @_;
my $where = {
- state => [ 'confirmed', 'fixed' ]
+ state => [ FixMyStreet::DB::Result::Problem->visible_states() ]
};
my @extra_cols = ();
if ($c->stash->{ward}) {
@@ -354,9 +354,11 @@ sub add_row {
? 'unknown'
: ($problem->{age} > $fourweeks ? 'older' : 'new');
# Fixed problems are either old or new
- push @{$fixed->{$council}{$duration_str}}, $problem if $problem->{state} eq 'fixed';
+ push @{$fixed->{$council}{$duration_str}}, $problem if
+ exists FixMyStreet::DB::Result::Problem->fixed_states()->{$problem->{state}};
# Open problems are either unknown, older, or new
- push @{$open->{$council}{$type}}, $problem if $problem->{state} eq 'confirmed';
+ push @{$open->{$council}{$type}}, $problem if
+ exists FixMyStreet::DB::Result::Problem->open_states->{$problem->{state}};
}
=head1 AUTHOR