diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 24 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 22 |
3 files changed, 66 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 92c89a864..f02b2cbe3 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -154,6 +154,26 @@ sub load_problem_or_display_error : Private { $c->stash->{problem} = $problem; + my $updates = $c->model('DB::Comment')->search( + { problem_id => $problem->id }, #, state => 'confirmed' }, + { + select => [ + 'id', 'name', 'text', + 'mark_fixed', + 'mark_open', + 'photo', + 'cobrand', + { + extract => 'epoch from confirmed', + -as => 'confirmed', + } + ], + order_by => 'confirmed' + } + ); + + $c->stash->{updates} = $updates; + return 1; } @@ -164,9 +184,6 @@ sub format_problem_for_display : Private { $c->stash->{banner} = $c->cobrand->generate_problem_banner($problem); - ( my $detail = $problem->detail ) =~ s/\r//g; - my @detail = split /\n{2,}/, $detail; - $c->stash->{detail} = \@detail; $c->stash->{allow_photo_upload} = $c->cobrand->allow_photo_display; $c->stash->{cobrand_alert_fields} = $c->cobrand->form_elements( '/alerts' ); diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index cbb68df0d..61d7c6ca5 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -17,6 +17,7 @@ __PACKAGE__->config( render_die => 1, expose_methods => [ 'loc', 'nget', 'tprintf', 'display_crossell_advert', 'prettify_epoch', + 'split_into_lines', ], ); @@ -105,5 +106,28 @@ sub prettify_epoch { return Page::prettify_epoch( $c->req, $epoch, $short_bool ); } +=head2 split_into_lines + + [% FOREACH line IN split_into_lines( text ) %] + <p> + [% line | html %] + </p> + [% END %] + +Split some text into an array of lines on double new lines. + +=cut + +sub split_into_lines { + my ( $self, $c, $text ) = @_; + + my @lines; + $text =~ s/\r//g; + + @lines = split /\n{2,}/, $text; + + return \@lines; +} + 1; diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index ecca3f7a8..6cd4a85f3 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -347,6 +347,28 @@ sub extract_problem_banner { return $result; } +=head2 extract_update_metas + + $metas = $mech->extract_update_metas; + +Returns an array ref of all the update meta information on the page. Strips whitespace from +the start and end of all of them. + +=cut + +sub extract_update_metas { + my $mech = shift; + + my $result = scraper { + process 'div#updates div.problem-update p em', 'meta[]', 'TEXT'; + } + ->scrape( $mech->response ); + + my @metas = map { s/^\s+//; s/\s+$//; $_; } @{ $result->{meta} }; + + return \@metas; +} + =head2 visible_form_values $hashref = $mech->visible_form_values( ); |