diff options
author | Struan Donald <struan@exo.org.uk> | 2011-08-22 11:22:33 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-08-22 11:22:33 +0100 |
commit | 44c31ab8efbd97086e17d26c819b1d5b4946ce43 (patch) | |
tree | 5a509a5006afd50f4c48f52fdf45ac9ac86ac054 /perllib/FixMyStreet/DB/Result/Problem.pm | |
parent | f93ff062c986847f97aef76673c2ca7742f1f125 (diff) | |
parent | a9a4fed583d7467c9c1f1fa56d42bcb75b4b488c (diff) |
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into open311-consumer
Conflicts:
t/app/model/problem.t
templates/web/default/report/new/fill_in_details.html
web/css/core.css
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 034c5d60d..9ff19efb6 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -143,6 +143,92 @@ use RABX; 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 = { + '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::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(); + +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, + 'closed' => 1, + }; + + return wantarray ? keys %{$states} : $states; +} + + my $tz = DateTime::TimeZone->new( name => "local" ); sub confirmed_local { @@ -308,6 +394,55 @@ 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; + + return exists $self->open_states->{ $self->state } ? 1 : 0; +} + + +=head2 is_fixed + +Returns 1 if the problem is in a fixed state otherwise 0. + +=cut + +sub is_fixed { + my $self = shift; + + 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. + +=cut + +sub is_visible { + my $self = shift; + + return exists $self->visible_states->{ $self->state } ? 1 : 0; +} + =head2 meta_line Returns a string to be used on a problem report page, describing some of the |