From 7b2fb6cd9934fae59d89cfeabf5260a54713c26f Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 15 Jun 2011 16:53:28 +0100 Subject: update report display to handle new statuses --- perllib/FixMyStreet/DB/Result/Problem.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 366024c7c..3e82e3784 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -284,6 +284,21 @@ sub get_photo_params { return $photo; } +sub is_open { + my $self = shift; + + my %open_states = ( + unconfirmed => 1, + partial => 1, + confirmed => 1, + 'planned' => 1, + 'investigating' => 1, + 'in progress' => 1, + ); + + return exists $open_states{ $self->state } ? 1 : 0; +} + =head2 meta_line Returns a string to be used on a problem report page, describing some of the -- cgit v1.2.3 From 7ef671b3177a69177f1412d1ece46b3e3d92f425 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 15 Jun 2011 16:55:06 +0100 Subject: docs and formatting --- perllib/FixMyStreet/DB/Result/Problem.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 3e82e3784..daedf5577 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -284,16 +284,22 @@ sub get_photo_params { return $photo; } +=head2 is_open + +Returns 1 if the problem is in a open state otherwise 0; + +=cut + sub is_open { my $self = shift; my %open_states = ( - unconfirmed => 1, - partial => 1, - confirmed => 1, - 'planned' => 1, + unconfirmed => 1, + partial => 1, + confirmed => 1, + 'planned' => 1, 'investigating' => 1, - 'in progress' => 1, + 'in progress' => 1, ); return exists $open_states{ $self->state } ? 1 : 0; -- cgit v1.2.3 From 3b328617e89a689e0f7b1cc957a7d282308af736 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 15 Jun 2011 18:24:52 +0100 Subject: send questionnaires for all open states --- perllib/FixMyStreet/DB/Result/Problem.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index daedf5577..47dac1e8e 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -305,6 +305,22 @@ sub is_open { return exists $open_states{ $self->state } ? 1 : 0; } +=head2 + + @states = FixMyStreet::DB::Problem::visible_states(); + +Returns a list of states that should be displayed on the site. + +=cut + +sub visible_states { + return ( + 'confirmed', 'planned', 'investigating', + 'in progress', 'fixed', 'fixed - council', + 'fixed - user', 'will not fix', + ); +} + =head2 meta_line Returns a string to be used on a problem report page, describing some of the -- cgit v1.2.3 From c9773705e4c611363474144f69182ad421187242 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 16 Jun 2011 12:17:35 +0100 Subject: handle new states in report display and updating --- perllib/FixMyStreet/DB/Result/Problem.pm | 108 +++++++++++++++++++++++++------ 1 file changed, 88 insertions(+), 20 deletions(-) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 47dac1e8e..2d3a8bccb 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -119,6 +119,74 @@ use Utils; with 'FixMyStreet::Roles::Abuser'; +=head2 + + @states = FixMyStreet::DB::Problem::open_states(); + +Get a list or states that are regarded as open. If called in +array context then returns an array of names, otherwise returns a +HASHREF. + +=cut + +sub open_states { + my $states = { + 'unconfirmed' => 1, + 'confirmed' => 1, + 'investigating' => 1, + 'planned' => 1, + 'in progress' => 1, + }; + + return wantarray ? keys %{$states} : $states; +} + +=head2 + + @states = FixMyStreet::DB::Problem::fixed_states(); + +Get a list or states that should be regarded as fixed. If called in +array context then returns an array of names, otherwise returns a +HASHREF. + +=cut + +sub fixed_states { + my $states = { + 'fixed' => 1, + 'fixed - user' => 1, + 'fixed - council' => 1, + }; + + return wantarray ? keys %{ $states } : $states; +} + +=head2 + + @states = FixMyStreet::DB::Problem::visible_states(); + +Get a list or states that should be visible on the site. If called in +array context then returns an array of names, otherwise returns a +HASHREF. + +=cut + +sub visible_states { + my $states = { + 'confirmed' => 1, + 'planned' => 1, + 'investigating' => 1, + 'in progress' => 1, + 'fixed' => 1, + 'fixed - council' => 1, + 'fixed - user' => 1, + 'will not fix' => 1, + }; + + return wantarray ? keys %{$states} : $states; +} + + my $tz = DateTime::TimeZone->new( name => "local" ); sub confirmed_local { @@ -286,39 +354,39 @@ sub get_photo_params { =head2 is_open -Returns 1 if the problem is in a open state otherwise 0; +Returns 1 if the problem is in a open state otherwise 0. =cut sub is_open { my $self = shift; - my %open_states = ( - unconfirmed => 1, - partial => 1, - confirmed => 1, - 'planned' => 1, - 'investigating' => 1, - 'in progress' => 1, - ); - - return exists $open_states{ $self->state } ? 1 : 0; + return exists $self->open_states->{ $self->state } ? 1 : 0; } -=head2 - @states = FixMyStreet::DB::Problem::visible_states(); +=head2 is_fixed -Returns a list of states that should be displayed on the site. +Returns 1 if the problem is in a fixed state otherwise 0. =cut -sub visible_states { - return ( - 'confirmed', 'planned', 'investigating', - 'in progress', 'fixed', 'fixed - council', - 'fixed - user', 'will not fix', - ); +sub is_fixed { + my $self = shift; + + return exists $self->fixed_states->{ $self->state } ? 1 : 0; +} + +=head2 is_visible + +Returns 1 if the problem should be displayed on the site otherwise 0. + +=cut + +sub is_visible { + my $self = shift; + + return exists $self->visible_states->{ $self->state } ? 1 : 0; } =head2 meta_line -- cgit v1.2.3 From 4d40d4632325a999b66dee1db36841dfeb60bcda Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 16 Jun 2011 12:40:39 +0100 Subject: rename will not fix to closed --- perllib/FixMyStreet/DB/Result/Problem.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 2d3a8bccb..65a2268b6 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -180,7 +180,7 @@ sub visible_states { 'fixed' => 1, 'fixed - council' => 1, 'fixed - user' => 1, - 'will not fix' => 1, + 'closed' => 1, }; return wantarray ? keys %{$states} : $states; -- cgit v1.2.3 From 2f3388de9ee449080febabd47876620c82d56895 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 21 Jun 2011 17:53:08 +0100 Subject: unconfirmed is not really an open state --- perllib/FixMyStreet/DB/Result/Problem.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 65a2268b6..c607cc89b 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -131,7 +131,6 @@ HASHREF. sub open_states { my $states = { - 'unconfirmed' => 1, 'confirmed' => 1, 'investigating' => 1, 'planned' => 1, -- cgit v1.2.3 From e907816b20bea99f7640f4ebb5e4ef1058fe0904 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 22 Jun 2011 18:06:49 +0100 Subject: is_closed utility method --- perllib/FixMyStreet/DB/Result/Problem.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index c607cc89b..fa3772310 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -160,6 +160,25 @@ sub fixed_states { return wantarray ? keys %{ $states } : $states; } +=head2 + + @states = FixMyStreet::DB::Problem::closed_states(); + +Get a list or states that should be regarded as closed. If called in +array context then returns an array of names, otherwise returns a +HASHREF. + +=cut + +sub closed_states { + my $states = { + 'closed' => 1, + }; + + return wantarray ? keys %{$states} : $states; +} + + =head2 @states = FixMyStreet::DB::Problem::visible_states(); @@ -376,6 +395,18 @@ sub is_fixed { return exists $self->fixed_states->{ $self->state } ? 1 : 0; } +=head2 is_closed + +Returns 1 if the problem is in a closed state otherwise 0. + +=cut + +sub is_closed { + my $self = shift; + + return exists $self->closed_states->{ $self->state } ? 1 : 0; +} + =head2 is_visible Returns 1 if the problem should be displayed on the site otherwise 0. -- cgit v1.2.3