aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Problem.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm45
1 files changed, 22 insertions, 23 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 3b7f8bcfd..f2df41f09 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -157,10 +157,10 @@ __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn");
__PACKAGE__->rabx_column('extra');
__PACKAGE__->rabx_column('geocode');
-use Image::Size;
-use Moose;
+use Moo;
use namespace::clean -except => [ 'meta' ];
use Utils;
+use Utils::Photo;
with 'FixMyStreet::Roles::Abuser',
'FixMyStreet::Roles::Extra';
@@ -462,7 +462,7 @@ sub bodies($) {
my $self = shift;
return {} unless $self->bodies_str;
my $bodies = $self->bodies_str_ids;
- my @bodies = FixMyStreet::App->model('DB::Body')->search({ id => $bodies })->all;
+ my @bodies = $self->result_source->schema->resultset('Body')->search({ id => $bodies })->all;
return { map { $_->id => $_ } @bodies };
}
@@ -477,6 +477,11 @@ sub url {
return "/report/" . $self->id;
}
+sub admin_url {
+ my ($self, $cobrand) = @_;
+ return $cobrand->admin_base_url . '/report_edit/' . $self->id;
+}
+
=head2 get_photo_params
Returns a hashref of details of the attached photo, if any, for use in templates.
@@ -491,7 +496,7 @@ sub get_photo_params {
# use Carp 'cluck';
# cluck "get_photo_params called"; # TEMPORARY die to make sure I've done right thing with Zurich templates
my $self = shift;
- return FixMyStreet::App::get_photo_params($self, 'id');
+ return Utils::Photo::get_photo_params($self, 'id');
}
=head2 is_open
@@ -628,7 +633,7 @@ sub body {
$body = join( _(' and '),
map {
my $name = $_->name;
- if ($c and mySociety::Config::get('AREA_LINKS_FROM_PROBLEMS')) {
+ if ($c and FixMyStreet->config('AREA_LINKS_FROM_PROBLEMS')) {
'<a href="' . $_->url($c) . '">' . $name . '</a>';
} else {
$name;
@@ -648,7 +653,7 @@ order of title.
sub response_templates {
my $problem = shift;
- return FixMyStreet::App->model('DB::ResponseTemplate')->search(
+ return $problem->result_source->schema->resultset('ResponseTemplate')->search(
{
body_id => $problem->bodies_str_ids
},
@@ -754,20 +759,17 @@ sub update_from_open311_service_request {
$status_notes = $request->{status_notes};
}
- my $update = FixMyStreet::App->model('DB::Comment')->new(
- {
- problem_id => $self->id,
- state => 'confirmed',
- created => $updated || \'current_timestamp',
- confirmed => \'current_timestamp',
- text => $status_notes,
- mark_open => 0,
- mark_fixed => 0,
- user => $system_user,
- anonymous => 0,
- name => $body->name,
- }
- );
+ my $update = $self->new_related(comments => {
+ state => 'confirmed',
+ created => $updated || \'current_timestamp',
+ confirmed => \'current_timestamp',
+ text => $status_notes,
+ mark_open => 0,
+ mark_fixed => 0,
+ user => $system_user,
+ anonymous => 0,
+ name => $body->name,
+ });
my $w3c = DateTime::Format::W3CDTF->new;
my $req_time = $w3c->parse_datetime( $request->{updated_datetime} );
@@ -894,7 +896,4 @@ sub get_time_spent {
return $admin_logs ? $admin_logs->get_column('sum_time_spent') : 0;
}
-# we need the inline_constructor bit as we don't inherit from Moose
-__PACKAGE__->meta->make_immutable( inline_constructor => 0 );
-
1;