aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm23
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm23
-rw-r--r--perllib/FixMyStreet/Roles/PhotoSet.pm35
3 files changed, 39 insertions, 42 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 85cdb29f0..25798edca 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -99,7 +99,8 @@ __PACKAGE__->rabx_column('extra');
use Moo;
use namespace::clean -except => [ 'meta' ];
-with 'FixMyStreet::Roles::Abuser';
+with 'FixMyStreet::Roles::Abuser',
+ 'FixMyStreet::Roles::PhotoSet';
my $stz = sub {
my ( $orig, $self ) = ( shift, shift );
@@ -147,26 +148,6 @@ sub confirm {
$self->confirmed( \'current_timestamp' );
}
-=head2 get_photoset
-
-Return a PhotoSet object for all photos attached to this field
-
- my $photoset = $obj->get_photoset;
- print $photoset->num_images;
- return $photoset->get_image_data(num => 0, size => 'full');
-
-=cut
-
-sub get_photoset {
- my ($self) = @_;
- my $class = 'FixMyStreet::App::Model::PhotoSet';
- eval "use $class";
- return $class->new({
- db_data => $self->photo,
- object => $self,
- });
-}
-
sub photos {
my $self = shift;
my $photoset = $self->get_photoset;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 2599f24ae..1ae719361 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -163,7 +163,8 @@ use Utils;
use FixMyStreet::Map::FMS;
with 'FixMyStreet::Roles::Abuser',
- 'FixMyStreet::Roles::Extra';
+ 'FixMyStreet::Roles::Extra',
+ 'FixMyStreet::Roles::PhotoSet';
=head2
@@ -809,26 +810,6 @@ sub latest_moderation_log_entry {
return $self->admin_log_entries->search({ action => 'moderation' }, { order_by => 'id desc' })->first;
}
-=head2 get_photoset
-
-Return a PhotoSet object for all photos attached to this field
-
- my $photoset = $obj->get_photoset;
- print $photoset->num_images;
- return $photoset->get_image_data(num => 0, size => 'full');
-
-=cut
-
-sub get_photoset {
- my ($self) = @_;
- my $class = 'FixMyStreet::App::Model::PhotoSet';
- eval "use $class";
- return $class->new({
- db_data => $self->photo,
- object => $self,
- });
-}
-
sub photos {
my $self = shift;
my $photoset = $self->get_photoset;
diff --git a/perllib/FixMyStreet/Roles/PhotoSet.pm b/perllib/FixMyStreet/Roles/PhotoSet.pm
new file mode 100644
index 000000000..9607b5049
--- /dev/null
+++ b/perllib/FixMyStreet/Roles/PhotoSet.pm
@@ -0,0 +1,35 @@
+package FixMyStreet::Roles::PhotoSet;
+use Moo::Role;
+
+=head1 NAME
+
+FixMyStreet::Roles::Photoset - role for accessing photosets
+
+=cut
+
+=head2 get_photoset
+
+Return a PhotoSet object for all photos attached to this field
+
+ my $photoset = $obj->get_photoset;
+ print $photoset->num_images;
+ return $photoset->get_image_data(num => 0, size => 'full');
+
+=cut
+
+sub get_photoset {
+ my ($self) = @_;
+ my $class = 'FixMyStreet::App::Model::PhotoSet';
+ eval "use $class";
+ return $class->new({
+ db_data => $self->photo,
+ object => $self,
+ });
+}
+
+sub get_first_image_fp {
+ my ($self) = @_;
+ return $self->get_photoset->get_image_data( num => 0, size => 'fp' );
+}
+
+1;