aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm12
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/BathNES.pm37
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm15
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm9
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm21
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm8
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm26
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm40
-rw-r--r--templates/web/base/my/anonymize.html2
-rw-r--r--templates/web/base/questionnaire/index.html2
-rw-r--r--templates/web/base/report/_council_sent_info.html2
-rw-r--r--templates/web/base/report/_report_meta_info.html2
-rw-r--r--templates/web/base/report/_update_state.html2
-rw-r--r--templates/web/base/report/updates.html2
-rw-r--r--templates/web/bathnes/report/_council_sent_info.html2
-rw-r--r--templates/web/cheshireeast/report/_council_sent_info.html2
-rw-r--r--templates/web/fixmystreet.com/report/_report_meta_info.html2
-rw-r--r--templates/web/hounslow/report/_council_sent_info.html2
-rw-r--r--templates/web/isleofwight/report/_council_sent_info.html2
-rw-r--r--templates/web/northamptonshire/report/_council_sent_info.html2
-rw-r--r--templates/web/oxfordshire/report/_main_sent_info.html2
-rw-r--r--templates/web/peterborough/report/_council_sent_info.html2
-rw-r--r--templates/web/tfl/report/_council_sent_info.html2
-rw-r--r--templates/web/zurich/admin/problem_row.html2
-rw-r--r--templates/web/zurich/admin/reports/edit.html2
-rw-r--r--templates/web/zurich/report/banner.html2
32 files changed, 114 insertions, 112 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 0e87d1e70..4c5c36106 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -295,7 +295,7 @@ sub map_features : Private {
@pins = map {
# Here we might have a DB::Problem or a DB::Result::Nearby, we always want the problem.
my $p = (ref $_ eq 'FixMyStreet::DB::Result::Nearby') ? $_->problem : $_;
- $p->pin_data($c, 'around');
+ $p->pin_data('around');
} @$on_map, @$nearby;
}
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index f7273ca0e..6fd4154b9 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -339,8 +339,9 @@ sub export_as_csv_updates : Private {
'text', 'user_name_display', 'reported_as',
],
filename => $self->csv_filename($c, 1),
+ user => $c->user_exists ? $c->user->obj : undef,
};
- $c->cobrand->call_hook("dashboard_export_updates_add_columns");
+ $c->cobrand->call_hook(dashboard_export_updates_add_columns => $csv);
$c->forward('generate_csv');
}
@@ -407,8 +408,11 @@ sub export_as_csv : Private {
'reported_as',
],
filename => $self->csv_filename($c, 0),
+ user => $c->user_exists ? $c->user->obj : undef,
+ category => $c->stash->{category},
+ contacts => $c->stash->{contacts},
};
- $c->cobrand->call_hook("dashboard_export_problems_add_columns");
+ $c->cobrand->call_hook(dashboard_export_problems_add_columns => $csv);
$c->forward('generate_csv');
}
@@ -460,7 +464,7 @@ sub generate_csv : Private {
my $objects = $c->stash->{csv}->{objects};
while ( my $obj = $objects->next ) {
- my $hashref = $obj->as_hashref($c, \%asked_for);
+ my $hashref = $obj->as_hashref(\%asked_for);
$hashref->{user_name_display} = $obj->anonymous
? '(anonymous)' : $obj->name;
@@ -554,7 +558,7 @@ sub heatmap : Local : Args(0) {
if ($c->get_param('ajax')) {
my @pins;
while ( my $problem = $problems->next ) {
- push @pins, $problem->pin_data($c, 'reports');
+ push @pins, $problem->pin_data('reports');
}
$c->stash->{pins} = \@pins;
$c->detach('/reports/ajax', [ 'dashboard/heatmap-list.html' ]);
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index f5c06d926..9d57c5e1d 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -157,7 +157,7 @@ sub get_problems : Private {
while ( my $problem = $rs->next ) {
$c->stash->{has_content}++;
- push @$pins, $problem->pin_data($c, 'my', private => 1);
+ push @$pins, $problem->pin_data('my', private => 1);
push @$problems, $problem;
}
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 991064f55..81d5b18b5 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -325,7 +325,7 @@ sub format_problem_for_display : Private {
$c->res->content_type('application/json; charset=utf-8');
# encode_json doesn't like DateTime objects, so strip them out
- my $report_hashref = $c->cobrand->problem_as_hashref( $problem, $c );
+ my $report_hashref = $c->cobrand->problem_as_hashref( $problem );
delete $report_hashref->{created};
delete $report_hashref->{confirmed};
@@ -333,7 +333,7 @@ sub format_problem_for_display : Private {
my $content = $json->encode(
{
report => $report_hashref,
- updates => $c->cobrand->updates_as_hashref( $problem, $c ),
+ updates => $c->cobrand->updates_as_hashref( $problem ),
}
);
$c->res->body( $content );
@@ -354,7 +354,7 @@ sub generate_map_tags : Private {
latitude => $problem->latitude,
longitude => $problem->longitude,
pins => $problem->used_map
- ? [ $problem->pin_data($c, 'report', type => 'big', draggable => 1) ]
+ ? [ $problem->pin_data('report', type => 'big', draggable => 1) ]
: [],
);
@@ -670,7 +670,7 @@ sub _nearby_json :Private {
# Want to treat these as if they were on map
$nearby = [ map { $_->problem } @$nearby ];
my @pins = map {
- my $p = $_->pin_data($c, 'around');
+ my $p = $_->pin_data('around');
[ $p->{latitude}, $p->{longitude}, $p->{colour},
$p->{id}, $p->{title}, $pin_size, JSON->false
]
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 10902eab9..d0f2a9394 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -826,7 +826,7 @@ sub stash_report_sort : Private {
sub add_row {
my ( $c, $problem, $body, $problems, $pins ) = @_;
push @{$problems->{$body}}, $problem;
- push @$pins, $problem->pin_data($c, 'reports');
+ push @$pins, $problem->pin_data('reports');
}
sub ajax : Private {
diff --git a/perllib/FixMyStreet/Cobrand/BathNES.pm b/perllib/FixMyStreet/Cobrand/BathNES.pm
index 10e74056f..2dc1a4297 100644
--- a/perllib/FixMyStreet/Cobrand/BathNES.pm
+++ b/perllib/FixMyStreet/Cobrand/BathNES.pm
@@ -163,9 +163,8 @@ sub categories_restriction {
# Do a manual prefetch of all staff users for contributed_by lookup
sub _dashboard_user_lookup {
my $self = shift;
- my $c = $self->{c};
- my @user_ids = $c->model('DB::User')->search(
+ my @user_ids = FixMyStreet::DB->resultset('User')->search(
{ from_body => { '!=' => undef } },
{ columns => [ 'id', 'email' ] })->all;
@@ -174,23 +173,22 @@ sub _dashboard_user_lookup {
}
sub dashboard_export_updates_add_columns {
- my $self = shift;
- my $c = $self->{c};
+ my ($self, $csv) = @_;
- return unless $c->user->has_body_permission_to('export_extra_columns');
+ return unless $csv->{user}->has_body_permission_to('export_extra_columns');
- push @{$c->stash->{csv}->{headers}}, "Staff User";
- push @{$c->stash->{csv}->{headers}}, "User Email";
- push @{$c->stash->{csv}->{columns}}, "staff_user";
- push @{$c->stash->{csv}->{columns}}, "user_email";
+ push @{$csv->{headers}}, "Staff User";
+ push @{$csv->{headers}}, "User Email";
+ push @{$csv->{columns}}, "staff_user";
+ push @{$csv->{columns}}, "user_email";
- $c->stash->{csv}->{objects} = $c->stash->{csv}->{objects}->search(undef, {
+ $csv->{objects} = $csv->{objects}->search(undef, {
'+columns' => ['user.email'],
join => 'user',
});
my $user_lookup = $self->_dashboard_user_lookup;
- $c->stash->{csv}->{extra_data} = sub {
+ $csv->{extra_data} = sub {
my $report = shift;
my $staff_user = '';
@@ -206,34 +204,33 @@ sub dashboard_export_updates_add_columns {
}
sub dashboard_export_problems_add_columns {
- my $self = shift;
- my $c = $self->{c};
+ my ($self, $csv) = @_;
- return unless $c->user->has_body_permission_to('export_extra_columns');
+ return unless $csv->{user}->has_body_permission_to('export_extra_columns');
- $c->stash->{csv}->{headers} = [
- @{ $c->stash->{csv}->{headers} },
+ $csv->{headers} = [
+ @{ $csv->{headers} },
"User Email",
"User Phone",
"Staff User",
"Attribute Data",
];
- $c->stash->{csv}->{columns} = [
- @{ $c->stash->{csv}->{columns} },
+ $csv->{columns} = [
+ @{ $csv->{columns} },
"user_email",
"user_phone",
"staff_user",
"attribute_data",
];
- $c->stash->{csv}->{objects} = $c->stash->{csv}->{objects}->search(undef, {
+ $csv->{objects} = $csv->{objects}->search(undef, {
'+columns' => ['user.email', 'user.phone'],
join => 'user',
});
my $user_lookup = $self->_dashboard_user_lookup;
- $c->stash->{csv}->{extra_data} = sub {
+ $csv->{extra_data} = sub {
my $report = shift;
my $staff_user = '';
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index 00264afea..75356dc87 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -124,19 +124,18 @@ sub map_type { 'Buckinghamshire' }
sub default_map_zoom { 3 }
sub _dashboard_export_add_columns {
- my $self = shift;
- my $c = $self->{c};
+ my ($self, $csv) = @_;
- push @{$c->stash->{csv}->{headers}}, "Staff User";
- push @{$c->stash->{csv}->{columns}}, "staff_user";
+ push @{$csv->{headers}}, "Staff User";
+ push @{$csv->{columns}}, "staff_user";
# All staff users, for contributed_by lookup
- my @user_ids = $c->model('DB::User')->search(
+ my @user_ids = FixMyStreet::DB->resultset('User')->search(
{ from_body => $self->body->id },
{ columns => [ 'id', 'email', ] })->all;
my %user_lookup = map { $_->id => $_->email } @user_ids;
- $c->stash->{csv}->{extra_data} = sub {
+ $csv->{extra_data} = sub {
my $report = shift;
my $staff_user = '';
if (my $contributed_by = $report->get_extra_metadata('contributed_by')) {
@@ -149,11 +148,11 @@ sub _dashboard_export_add_columns {
}
sub dashboard_export_updates_add_columns {
- shift->_dashboard_export_add_columns;
+ shift->_dashboard_export_add_columns(@_);
}
sub dashboard_export_problems_add_columns {
- shift->_dashboard_export_add_columns;
+ shift->_dashboard_export_add_columns(@_);
}
# Enable adding/editing of parish councils in the admin
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index bd8b7e4b4..82b3b7f45 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -1248,15 +1248,13 @@ sub get_geocoder {
sub problem_as_hashref {
my $self = shift;
my $problem = shift;
- my $ctx = shift;
- return $problem->as_hashref( $ctx );
+ return $problem->as_hashref;
}
sub updates_as_hashref {
my $self = shift;
my $problem = shift;
- my $ctx = shift;
return {};
}
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index aa6c9a5a5..31db0fd4e 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -203,13 +203,12 @@ sub available_permissions {
}
sub dashboard_export_problems_add_columns {
- my $self = shift;
- my $c = $self->{c};
+ my ($self, $csv) = @_;
- push @{$c->stash->{csv}->{headers}}, "HIAMS/Exor Ref";
- push @{$c->stash->{csv}->{columns}}, "external_ref";
+ push @{$csv->{headers}}, "HIAMS/Exor Ref";
+ push @{$csv->{columns}}, "external_ref";
- $c->stash->{csv}->{extra_data} = sub {
+ $csv->{extra_data} = sub {
my $report = shift;
# Try and get a HIAMS reference first of all
my $ref = $report->get_extra_metadata('customer_reference');
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index 9620c6b9e..e085b8bd6 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -242,11 +242,10 @@ sub available_permissions {
}
sub dashboard_export_problems_add_columns {
- my $self = shift;
- my $c = $self->{c};
+ my ($self, $csv) = @_;
- $c->stash->{csv}->{headers} = [
- map { $_ eq 'Ward' ? 'Borough' : $_ } @{ $c->stash->{csv}->{headers} },
+ $csv->{headers} = [
+ map { $_ eq 'Ward' ? 'Borough' : $_ } @{ $csv->{headers} },
"Agent responsible",
"Safety critical",
"Delivered to",
@@ -255,8 +254,8 @@ sub dashboard_export_problems_add_columns {
"Reassigned by",
];
- $c->stash->{csv}->{columns} = [
- @{ $c->stash->{csv}->{columns} },
+ $csv->{columns} = [
+ @{ $csv->{columns} },
"agent_responsible",
"safety_critical",
"delivered_to",
@@ -265,18 +264,18 @@ sub dashboard_export_problems_add_columns {
"reassigned_by",
];
- if ($c->stash->{category}) {
- my ($contact) = grep { $_->category eq $c->stash->{category} } @{$c->stash->{contacts}};
+ if ($csv->{category}) {
+ my ($contact) = grep { $_->category eq $csv->{category} } @{$csv->{contacts}};
if ($contact) {
foreach (@{$contact->get_metadata_for_storage}) {
next if $_->{code} eq 'safety_critical';
- push @{$c->stash->{csv}->{columns}}, "extra.$_->{code}";
- push @{$c->stash->{csv}->{headers}}, $_->{description};
+ push @{$csv->{columns}}, "extra.$_->{code}";
+ push @{$csv->{headers}}, $_->{description};
}
}
}
- $c->stash->{csv}->{extra_data} = sub {
+ $csv->{extra_data} = sub {
my $report = shift;
my $agent = $report->shortlisted_user;
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index 772310545..8d464ca7b 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -398,9 +398,9 @@ sub link_to_council_cobrand {
$handler->moniker ne $self->{c}->cobrand->moniker
) {
my $url = sprintf("%s%s", $handler->base_url, $problem->url);
- return sprintf("<a href='%s'>%s</a>", $url, $problem->body( $self->{c} ));
+ return sprintf("<a href='%s'>%s</a>", $url, $problem->body);
} else {
- return $problem->body( $self->{c} );
+ return $problem->body;
}
}
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 4551fcc4a..e33edc792 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -131,9 +131,8 @@ sub problem_has_user_response {
sub problem_as_hashref {
my $self = shift;
my $problem = shift;
- my $ctx = shift;
- my $hashref = $problem->as_hashref( $ctx );
+ my $hashref = $problem->as_hashref;
if ( $problem->state eq 'submitted' ) {
for my $var ( qw( photo is_fixed meta ) ) {
@@ -171,7 +170,6 @@ sub problem_as_hashref {
sub updates_as_hashref {
my $self = shift;
my $problem = shift;
- my $ctx = shift;
my $hashref = {};
@@ -182,7 +180,7 @@ sub updates_as_hashref {
$hashref->{details} = FixMyStreet::App::View::Web::add_links(
$problem->get_extra_metadata('public_response') || '' );
} else {
- $hashref->{details} = sprintf( _('Assigned to %s'), $problem->body($ctx)->name );
+ $hashref->{details} = sprintf( _('Assigned to %s'), $problem->body->name );
}
}
@@ -1319,7 +1317,7 @@ sub export_as_csv {
my $report = shift;
my $body_name = "";
- if ( my $external_body = $report->body($c) ) {
+ if ( my $external_body = $report->body ) {
$body_name = $external_body->name || '[Unknown body]';
}
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 2ef8925e6..a20c336a5 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -262,7 +262,8 @@ about an update. Can include HTML.
=cut
sub meta_line {
- my ( $self, $c ) = @_;
+ my ( $self, $user ) = @_;
+ my $cobrand = $self->result_source->schema->cobrand;
my $meta = '';
@@ -292,9 +293,9 @@ sub meta_line {
$body = 'Island Roads';
}
}
- my $cobrand_always_view_body_user = $c->cobrand->call_hook("always_view_body_contribute_details");
+ my $cobrand_always_view_body_user = $cobrand->call_hook("always_view_body_contribute_details");
my $can_view_contribute = $cobrand_always_view_body_user ||
- ($c->user_exists && $c->user->has_permission_to('view_body_contribute_details', $self->problem->bodies_str_ids));
+ ($user && $user->has_permission_to('view_body_contribute_details', $self->problem->bodies_str_ids));
if ($self->text) {
if ($can_view_contribute) {
$meta = sprintf( _( 'Posted by <strong>%s</strong> (%s) at %s' ), $body, $user_name, Utils::prettify_dt( $self->confirmed ) );
@@ -320,21 +321,23 @@ sub meta_line {
};
sub problem_state_processed {
- my ( $self, $c ) = @_;
+ my $self = shift;
return 'fixed - user' if $self->mark_fixed;
return 'confirmed' if $self->mark_open;
- my $cobrand_state = $c->cobrand->call_hook(problem_state_processed => $self);
+ my $cobrand = $self->result_source->schema->cobrand;
+ my $cobrand_state = $cobrand->call_hook(problem_state_processed => $self);
return $cobrand_state || $self->problem_state;
}
sub problem_state_display {
- my ( $self, $c ) = @_;
+ my $self = shift;
- my $state = $self->problem_state_processed($c);
+ my $state = $self->problem_state_processed;
return '' unless $state;
- my $cobrand_name = $c->cobrand->moniker;
+ my $cobrand = $self->result_source->schema->cobrand;
+ my $cobrand_name = $cobrand->moniker;
my $names = join(',,', @{$self->problem->body_names});
if ($names =~ /(Bromley|Isle of Wight|TfL)/) {
($cobrand_name = lc $1) =~ s/ //g;
@@ -370,7 +373,8 @@ sub hide {
}
sub as_hashref {
- my ($self, $c, $cols) = @_;
+ my ($self, $cols) = @_;
+ my $cobrand = $self->result_source->schema->cobrand;
my $out = {
id => $self->id,
@@ -380,13 +384,13 @@ sub as_hashref {
created => $self->created,
};
- $out->{problem_state} = $self->problem_state_processed($c);
+ $out->{problem_state} = $self->problem_state_processed;
$out->{photos} = [ map { $_->{url} } @{$self->photos} ] if !$cols || $cols->{photos};
if ($self->confirmed) {
$out->{confirmed} = $self->confirmed if !$cols || $cols->{confirmed};
- $out->{confirmed_pp} = $c->cobrand->prettify_dt( $self->confirmed ) if !$cols || $cols->{confirmed_pp};
+ $out->{confirmed_pp} = $cobrand->prettify_dt( $self->confirmed ) if !$cols || $cols->{confirmed_pp};
}
return $out;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 0653de32b..705f07f79 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -631,13 +631,14 @@ meta data about the report.
=cut
sub meta_line {
- my ( $problem, $c ) = @_;
+ my ( $problem, $user ) = @_;
+ my $cobrand = $problem->result_source->schema->cobrand;
my $date_time = Utils::prettify_dt( $problem->confirmed );
my $meta = '';
my $category = $problem->category_display;
- $category = $c->cobrand->call_hook(change_category_text => $category) || $category;
+ $category = $cobrand->call_hook(change_category_text => $category) || $category;
if ( $problem->anonymous ) {
if ( $problem->service and $category && $category ne _('Other') ) {
@@ -656,8 +657,8 @@ sub meta_line {
} else {
my $problem_name = $problem->name;
- if ($c->user_exists and
- $c->user->has_permission_to('view_body_contribute_details', $problem->bodies_str_ids) and
+ if ($user and
+ $user->has_permission_to('view_body_contribute_details', $problem->bodies_str_ids) and
$problem->name ne $problem->user->name) {
$problem_name = sprintf('%s (%s)', $problem->name, $problem->user->name );
}
@@ -692,12 +693,12 @@ sub nearest_address {
}
sub body {
- my ( $problem, $c ) = @_;
+ my ( $problem, $link ) = @_;
my $body;
if ($problem->external_body) {
if ($problem->cobrand eq 'zurich') {
my $cache = $problem->result_source->schema->cache;
- return $cache->{bodies}{$problem->external_body} //= $c->model('DB::Body')->find({ id => $problem->external_body });
+ return $cache->{bodies}{$problem->external_body} //= FixMyStreet::DB->resultset('Body')->find({ id => $problem->external_body });
} else {
$body = FixMyStreet::Template::html_filter($problem->external_body);
}
@@ -705,7 +706,7 @@ sub body {
my $bodies = $problem->bodies;
my @body_names = sort map {
my $name = $_->name;
- if ($c and FixMyStreet->config('AREA_LINKS_FROM_PROBLEMS')) {
+ if ($link and FixMyStreet->config('AREA_LINKS_FROM_PROBLEMS')) {
'<a href="' . $_->url . '">' . FixMyStreet::Template::html_filter($name) . '</a>';
} else {
FixMyStreet::Template::html_filter($name);
@@ -810,9 +811,10 @@ sub can_display_external_id {
# This can return HTML and is safe, so returns a FixMyStreet::Template::SafeString
sub duration_string {
- my ( $problem, $c ) = @_;
- my $body = $c->cobrand->call_hook(link_to_council_cobrand => $problem) || $problem->body($c);
- my $handler = $c->cobrand->call_hook(get_body_handler_for_problem => $problem);
+ my $problem = shift;
+ my $cobrand = $problem->result_source->schema->cobrand;
+ my $body = $cobrand->call_hook(link_to_council_cobrand => $problem) || $problem->body(1);
+ my $handler = $cobrand->call_hook(get_body_handler_for_problem => $problem);
if ( $handler && $handler->call_hook('is_council_with_case_management') ) {
my $s = sprintf(_('Received by %s moments later'), $body);
return FixMyStreet::Template::SafeString->new($s);
@@ -896,7 +898,8 @@ sub resend {
}
sub as_hashref {
- my ($self, $c, $cols) = @_;
+ my ($self, $cols) = @_;
+ my $cobrand = $self->result_source->schema->cobrand;
my $state_t = FixMyStreet::DB->resultset("State")->display($self->state);
@@ -916,11 +919,11 @@ sub as_hashref {
};
$out->{is_fixed} = $self->fixed_states->{ $self->state } ? 1 : 0 if !$cols || $cols->{is_fixed};
$out->{photos} = [ map { $_->{url} } @{$self->photos} ] if !$cols || $cols->{photos};
- $out->{meta} = $self->confirmed ? $self->meta_line( $c ) : '' if !$cols || $cols->{meta};
- $out->{created_pp} = $c->cobrand->prettify_dt( $self->created ) if !$cols || $cols->{created_pp};
+ $out->{meta} = $self->confirmed ? $self->meta_line : '' if !$cols || $cols->{meta};
+ $out->{created_pp} = $cobrand->prettify_dt( $self->created ) if !$cols || $cols->{created_pp};
if ($self->confirmed) {
$out->{confirmed} = $self->confirmed if !$cols || $cols->{confirmed};
- $out->{confirmed_pp} = $c->cobrand->prettify_dt( $self->confirmed ) if !$cols || $cols->{confirmed_pp};
+ $out->{confirmed_pp} = $cobrand->prettify_dt( $self->confirmed ) if !$cols || $cols->{confirmed_pp};
}
return $out;
}
@@ -973,10 +976,11 @@ has get_cobrand_logged => (
sub pin_data {
- my ($self, $c, $page, %opts) = @_;
- my $colour = $c->cobrand->pin_colour($self, $page);
+ my ($self, $page, %opts) = @_;
+ my $cobrand = $self->result_source->schema->cobrand;
+ my $colour = $cobrand->pin_colour($self, $page);
my $title = $opts{private} ? $self->title : $self->title_safe;
- $title = $c->cobrand->call_hook(pin_hover_title => $self, $title) || $title;
+ $title = $cobrand->call_hook(pin_hover_title => $self, $title) || $title;
{
latitude => $self->latitude,
longitude => $self->longitude,
@@ -986,7 +990,7 @@ sub pin_data {
problem => $self,
draggable => $opts{draggable},
type => $opts{type},
- base_url => $c->cobrand->relative_url_for_report($self),
+ base_url => $cobrand->relative_url_for_report($self),
}
};
diff --git a/templates/web/base/my/anonymize.html b/templates/web/base/my/anonymize.html
index e82a03ce0..1159d4ebc 100644
--- a/templates/web/base/my/anonymize.html
+++ b/templates/web/base/my/anonymize.html
@@ -10,7 +10,7 @@
<input class="btn-primary" type="submit" name="hide" value="[% loc('Hide my name in this update') %]">
[% ELSIF problem %]
[% IF problem.bodies_str %]
- <p>[% tprintf(loc('Your name has already been sent to %s, but we can hide it on this page:'), problem.body(c)) %]</p>
+ <p>[% tprintf(loc('Your name has already been sent to %s, but we can hide it on this page:'), problem.body) %]</p>
[% END %]
<input type="hidden" name="problem" value="[% problem.id %]">
<input class="btn-primary" type="submit" name="hide" value="[% loc('Hide my name on this report') %]">
diff --git a/templates/web/base/questionnaire/index.html b/templates/web/base/questionnaire/index.html
index 7a08d461d..00911c5b1 100644
--- a/templates/web/base/questionnaire/index.html
+++ b/templates/web/base/questionnaire/index.html
@@ -49,7 +49,7 @@
<h3 class="questionnaire-report-reminder__report-title">
<a href="/report/[% problem.id %]">[% problem.title | html %]</a>
</h3>
- <p class="questionnaire-report-reminder__report-meta">[% problem.meta_line(c) | html %]</p>
+ <p class="questionnaire-report-reminder__report-meta">[% problem.meta_line(c.user) | html %]</p>
[% IF updates.size %]
<p class="questionnaire-report-reminder__last-update-header">
<strong>[% loc('Last update') %]</strong>
diff --git a/templates/web/base/report/_council_sent_info.html b/templates/web/base/report/_council_sent_info.html
index dca74f994..ae0f80a2e 100644
--- a/templates/web/base/report/_council_sent_info.html
+++ b/templates/web/base/report/_council_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || problem.can_display_external_id %]
<p class="council_sent_info">
[%- IF problem.can_display_external_id %]
diff --git a/templates/web/base/report/_report_meta_info.html b/templates/web/base/report/_report_meta_info.html
index e2a6412a3..73e897e34 100644
--- a/templates/web/base/report/_report_meta_info.html
+++ b/templates/web/base/report/_report_meta_info.html
@@ -1,4 +1,4 @@
-[% problem.meta_line(c) | html %]
+[% problem.meta_line(c.user) | html %]
[% IF c.user_exists AND c.user.id == problem.user_id AND !problem.anonymous %]
<small>(<a href="/my/anonymize?problem=[% problem.id | uri %]" class="js-hide-name">[% loc('Hide your name?') %]</a>)</small>
[% END %]
diff --git a/templates/web/base/report/_update_state.html b/templates/web/base/report/_update_state.html
index 0274d7695..0bc4bfb52 100644
--- a/templates/web/base/report/_update_state.html
+++ b/templates/web/base/report/_update_state.html
@@ -4,7 +4,7 @@
OR update.mark_fixed
OR update.mark_open
%]
- <p class="meta-2">[% loc('State changed to:') %] [% update.problem_state_display(c) %]</p>
+ <p class="meta-2">[% loc('State changed to:') %] [% update.problem_state_display %]</p>
[%- global.last_state = update_state %]
[%- IF update_state == "" AND update.mark_fixed %][% global.last_state = 'fixed - user' %][% END %]
[%- IF update_state == "" AND update.mark_open %][% global.last_state = 'confirmed' %][% END %]
diff --git a/templates/web/base/report/updates.html b/templates/web/base/report/updates.html
index 93bae4d64..d65f1a287 100644
--- a/templates/web/base/report/updates.html
+++ b/templates/web/base/report/updates.html
@@ -27,6 +27,6 @@
[% RETURN %]
[% END %]
- [% update.meta_line(c) %]
+ [% update.meta_line(c.user) %]
[% END %]
diff --git a/templates/web/bathnes/report/_council_sent_info.html b/templates/web/bathnes/report/_council_sent_info.html
index 1963020bc..c7e1eaf1d 100644
--- a/templates/web/bathnes/report/_council_sent_info.html
+++ b/templates/web/bathnes/report/_council_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || problem.whensent %]
<p class="council_sent_info">
[%- IF problem.whensent %]
diff --git a/templates/web/cheshireeast/report/_council_sent_info.html b/templates/web/cheshireeast/report/_council_sent_info.html
index 1963020bc..c7e1eaf1d 100644
--- a/templates/web/cheshireeast/report/_council_sent_info.html
+++ b/templates/web/cheshireeast/report/_council_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || problem.whensent %]
<p class="council_sent_info">
[%- IF problem.whensent %]
diff --git a/templates/web/fixmystreet.com/report/_report_meta_info.html b/templates/web/fixmystreet.com/report/_report_meta_info.html
index 2eab84c9e..82d4b289a 100644
--- a/templates/web/fixmystreet.com/report/_report_meta_info.html
+++ b/templates/web/fixmystreet.com/report/_report_meta_info.html
@@ -1,4 +1,4 @@
-[% problem.meta_line(c) | html %]
+[% problem.meta_line(c.user) | html %]
[% IF c.cobrand.moniker != problem.get_cobrand_logged.moniker AND problem.get_cobrand_logged.is_council %]
using <a href="https://www.fixmystreet.com/pro/">FixMyStreet Pro</a>
[% END %]
diff --git a/templates/web/hounslow/report/_council_sent_info.html b/templates/web/hounslow/report/_council_sent_info.html
index 921f17f5f..97a7c4ca5 100644
--- a/templates/web/hounslow/report/_council_sent_info.html
+++ b/templates/web/hounslow/report/_council_sent_info.html
@@ -1,5 +1,5 @@
[% SET can_display_external_id = problem.external_id AND c.user_exists AND c.user.belongs_to_body(problem.bodies_str) %]
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || can_display_external_id %]
<p class="council_sent_info">
[% duration_clause %]
diff --git a/templates/web/isleofwight/report/_council_sent_info.html b/templates/web/isleofwight/report/_council_sent_info.html
index d9edac902..a2933d81e 100644
--- a/templates/web/isleofwight/report/_council_sent_info.html
+++ b/templates/web/isleofwight/report/_council_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || problem.can_display_external_id %]
<p class="council_sent_info">
[%- IF problem.can_display_external_id %]
diff --git a/templates/web/northamptonshire/report/_council_sent_info.html b/templates/web/northamptonshire/report/_council_sent_info.html
index 6329c51ad..5a53f2034 100644
--- a/templates/web/northamptonshire/report/_council_sent_info.html
+++ b/templates/web/northamptonshire/report/_council_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || problem.whensent %]
<p class="council_sent_info">
[%- IF problem.whensent AND NOT c.cobrand.is_defect(problem) %]
diff --git a/templates/web/oxfordshire/report/_main_sent_info.html b/templates/web/oxfordshire/report/_main_sent_info.html
index 9865153d3..7066ebe5d 100644
--- a/templates/web/oxfordshire/report/_main_sent_info.html
+++ b/templates/web/oxfordshire/report/_main_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause %]
<p class="council_sent_info">[% duration_clause %]</p>
[% END %]
diff --git a/templates/web/peterborough/report/_council_sent_info.html b/templates/web/peterborough/report/_council_sent_info.html
index 1963020bc..c7e1eaf1d 100644
--- a/templates/web/peterborough/report/_council_sent_info.html
+++ b/templates/web/peterborough/report/_council_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || problem.whensent %]
<p class="council_sent_info">
[%- IF problem.whensent %]
diff --git a/templates/web/tfl/report/_council_sent_info.html b/templates/web/tfl/report/_council_sent_info.html
index ef6cca079..472c6ce10 100644
--- a/templates/web/tfl/report/_council_sent_info.html
+++ b/templates/web/tfl/report/_council_sent_info.html
@@ -1,4 +1,4 @@
-[% SET duration_clause = problem.duration_string(c) %]
+[% SET duration_clause = problem.duration_string %]
[% IF duration_clause || problem.whensent %]
<p class="council_sent_info">
[%- IF problem.whensent %]
diff --git a/templates/web/zurich/admin/problem_row.html b/templates/web/zurich/admin/problem_row.html
index 08857f165..a2805d6dc 100644
--- a/templates/web/zurich/admin/problem_row.html
+++ b/templates/web/zurich/admin/problem_row.html
@@ -31,7 +31,7 @@
[%- IF p_body.parent.parent.id -%][%# ...it's a subdivision %]
[% PROCESS value_or_nbsp value=p_body.name %]
[%- ELSIF problem.external_body %]
- [% PROCESS value_or_nbsp value=problem.body(c).name %]
+ [% PROCESS value_or_nbsp value=problem.body.name %]
[%- ELSE -%]
&nbsp;
[%- END -%]
diff --git a/templates/web/zurich/admin/reports/edit.html b/templates/web/zurich/admin/reports/edit.html
index c88c63307..4a35192f0 100644
--- a/templates/web/zurich/admin/reports/edit.html
+++ b/templates/web/zurich/admin/reports/edit.html
@@ -272,7 +272,7 @@
[% ELSE %]
[% loc('Message to competent body:') %]
[% END %]
- [% problem.body(c).endpoint %]
+ [% problem.body.endpoint %]
</h2>
<div class="admin-external-message">
[% problem.extra.external_message | html_para %]
diff --git a/templates/web/zurich/report/banner.html b/templates/web/zurich/report/banner.html
index 8814dc986..b8ba7fa43 100644
--- a/templates/web/zurich/report/banner.html
+++ b/templates/web/zurich/report/banner.html
@@ -1,5 +1,5 @@
[% USE date %]
-[% problem_hashref = c.cobrand.problem_as_hashref(problem, c) %]
+[% problem_hashref = c.cobrand.problem_as_hashref(problem) %]
<div class="banner banner--[% problem_hashref.banner_id %]">
<p>[% problem_hashref.state_t %]</p>
</div>