aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm11
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm20
2 files changed, 31 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index bac3c5b17..691a4ecc9 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -4,6 +4,8 @@ use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller'; }
+use Path::Class;
+
=head1 NAME
FixMyStreet::App::Controller::Report::Update
@@ -68,6 +70,7 @@ sub report_update : Path : Args(0) {
$c->forward('setup_page')
&& $c->forward('process_user')
&& $c->forward('process_update')
+ && $c->forward('/report/new/process_photo')
&& $c->forward('check_for_errors')
or $c->go( '/report/display', [ $c->req->param('id') ] );
@@ -212,6 +215,14 @@ sub save_update : Private {
$update->confirm;
}
+ # If there was a photo add that too
+ if ( my $fileid = $c->stash->{upload_fileid} ) {
+ my $file = file( $c->config->{UPLOAD_CACHE}, "$fileid.jpg" );
+ my $blob = $file->slurp;
+ $file->remove;
+ $update->photo($blob);
+ }
+
if ( $update->in_storage ) {
$update->update;
} else {
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 7259087be..73c5876d6 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -97,4 +97,24 @@ sub confirm {
$self->state( 'confirmed' );
$self->confirmed( \'ms_current_timestamp()' );
}
+
+=head2 get_photo_params
+
+Returns a hashref of details of any attached photo for use in templates.
+Hashref contains height, width and url keys.
+
+=cut
+
+sub get_photo_params {
+ my $self = shift;
+
+ return {} unless $self->photo;
+
+ my $photo = {};
+ ( $photo->{width}, $photo->{height} ) =
+ Image::Size::imgsize( \$self->photo );
+ $photo->{url} = '/photo/?c=' . $self->id;
+
+ return $photo;
+}
1;