diff options
author | Struan Donald <struan@exo.org.uk> | 2013-02-12 12:12:01 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-02-12 12:12:01 +0000 |
commit | 8d9bc808b3288aa5a00975c0e981b9d857836ed0 (patch) | |
tree | f7071977645c1b1690063e9125cea44a1fadfbf5 | |
parent | 29d1f70b3a2df58ba6c3212080744fc48dd4cb5f (diff) |
move as_hashref call to the cobrand to enable applying any cobrand based workflow rules
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 30 |
3 files changed, 39 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 1ac8bdd5c..6b222be4c 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -173,7 +173,7 @@ sub format_problem_for_display : Private { if ( $c->stash->{ajax} ) { $c->res->content_type('application/json; charset=utf-8'); my $content = JSON->new->utf8(1)->encode( - $problem->as_hashref( $c ) + $c->cobrand->problem_as_hashref( $problem, $c ) ); $c->res->body( $content ); return 1; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index d99950ad0..2292a6cf3 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -818,5 +818,13 @@ Set to an indent string if you wish to override the default email handling. sub email_indent { undef; } +sub problem_as_hashref { + my $self = shift; + my $problem = shift; + my $ctx = shift; + + return $problem->as_hashref( $ctx ); +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index c7396f0c3..30365e0a3 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -51,6 +51,36 @@ sub prettify_dt { return Utils::prettify_dt( $dt, 'zurich' ); } +sub problem_as_hashref { + my $self = shift; + my $problem = shift; + my $ctx = shift; + + my $hashref = $problem->as_hashref( $ctx ); + + if ( $problem->state eq 'unconfirmed' ) { + for my $var ( qw( photo category detail state state_t is_fixed meta ) ) { + delete $hashref->{ $var }; + } + $hashref->{detail} = _('This report is awating moderation'); + $hashref->{state} = 'submitted'; + $hashref->{state_t} = _('Submitted'); + } else { + if ( $problem->state eq 'confirmed' ) { + $hashref->{state} = 'open'; + $hashref->{state_t} = _('Open'); + } elsif ( $problem->is_fixed ) { + $hashref->{state} = 'closed'; + $hashref->{state_t} = _('Closed'); + } elsif ( $problem->state eq 'in progress' || $problem->state eq 'planned' ) { + $hashref->{state} = 'in progress'; + $hashref->{state_t} = _('In progress'); + } + } + + return $hashref; +} + sub remove_redundant_areas { my $self = shift; my $all_areas = shift; |