diff options
author | Matthew Somerville <matthew@mysociety.org> | 2016-01-12 15:28:15 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-01-12 15:28:15 +0000 |
commit | de6df5e30d4801afc560e93c833a692a117b9547 (patch) | |
tree | d66e9958c7e976e779c0e23e88631bd9c5af777d /perllib | |
parent | 0715183153048e2bdbf838d6206ae50103d50384 (diff) |
Remove most passing of Catalyst to PhotoSet.
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Photo.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Model/PhotoSet.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 10 |
5 files changed, 10 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index f2d6040ae..c42916acb 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -1498,7 +1498,7 @@ sub rotate_photo : Private { return unless $direction eq _('Rotate Left') or $direction eq _('Rotate Right'); my $problem = $c->stash->{problem}; - my $fileid = $problem->get_photoset($c)->rotate_image( + my $fileid = $problem->get_photoset->rotate_image( $index, $direction eq _('Rotate Left') ? -90 : 90 ) or return; @@ -1529,7 +1529,7 @@ sub remove_photo : Private { if ($keys eq 'ALL') { $object->photo(undef); } else { - my $fileids = $object->get_photoset($c)->remove_images($keys); + my $fileids = $object->get_photoset->remove_images($keys); $object->photo($fileids); } return 1; diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index f4866cc26..5a5771488 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -74,8 +74,8 @@ sub index :LocalRegex('^(c/)?(\d+)(?:\.(\d+))?(?:\.(full|tn|fp))?\.jpeg$') { my $photo; if ($item->can('get_photoset')) { - $photo = $item->get_photoset( $c ) - ->get_image_data( num => $photo_number, size => $size ) + $photo = $item->get_photoset + ->get_image_data( num => $photo_number, size => $size, default => $c->cobrand->default_photo_resize ) or $c->detach( 'no_photo' ); } else { $photo = $item->photo; diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 4632f450d..db524ada4 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -449,7 +449,7 @@ sub initialize_report : Private { $c->stash->{partial_token} = $token if $report; # Stash the photo IDs for "already got" display - $c->stash->{upload_fileid} = $report->get_photoset($c)->data; + $c->stash->{upload_fileid} = $report->get_photoset->data; } else { # no point keeping it if it is done. diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm index 7b95e93d4..9abe1dce7 100644 --- a/perllib/FixMyStreet/App/Model/PhotoSet.pm +++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm @@ -222,7 +222,7 @@ sub get_image_data { } elsif ( $size eq 'full' ) { # do nothing } else { - $photo = _shrink( $photo, $self->c->cobrand->default_photo_resize || '250x250' ); + $photo = _shrink( $photo, $args{default} || '250x250' ); } return $photo; @@ -252,7 +252,6 @@ sub remove_images { my $new_set = (ref $self)->new({ data_items => \@items, - c => $self->c, object => $self->object, }); @@ -272,7 +271,6 @@ sub rotate_image { my $new_set = (ref $self)->new({ data_items => \@items, - c => $self->c, object => $self->object, }); diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 237785820..745d88629 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -487,9 +487,8 @@ sub admin_url { Returns a hashref of details of the attached photo, if any, for use in templates. -NB: this method doesn't currently support multiple photos gracefully. - -Use get_photoset($c) instead to do the right thing with reports with 0, 1, or more photos. +NB: this method only returns the first if there are multiple photos. Use +get_photoset if you wish to access multiple photos. =cut @@ -858,18 +857,17 @@ sub latest_moderation_log_entry { Return a PhotoSet object for all photos attached to this field - my $photoset = $obj->get_photoset( $c ); + my $photoset = $obj->get_photoset; print $photoset->num_images; return $photoset->get_image_data(num => 0, size => 'full'); =cut sub get_photoset { - my ($self, $c) = @_; + my ($self) = @_; my $class = 'FixMyStreet::App::Model::PhotoSet'; eval "use $class"; return $class->new({ - c => $c, db_data => $self->photo, object => $self, }); |