aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Body.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Body.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Body.pm45
1 files changed, 37 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm
index 663181746..95debc910 100644
--- a/perllib/FixMyStreet/DB/Result/Body.pm
+++ b/perllib/FixMyStreet/DB/Result/Body.pm
@@ -117,6 +117,12 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
+ "roles",
+ "FixMyStreet::DB::Result::Role",
+ { "foreign.body_id" => "self.id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+__PACKAGE__->has_many(
"user_body_permissions",
"FixMyStreet::DB::Result::UserBodyPermission",
{ "foreign.body_id" => "self.id" },
@@ -130,8 +136,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07035 @ 2019-04-25 12:06:39
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8CuxbffDaYS7TFlgff1nEg
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2019-05-23 18:03:28
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9sFgYQ9qhnZNcz3kUFYuvg
__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn");
__PACKAGE__->rabx_column('extra');
@@ -187,11 +193,7 @@ sub first_area_children {
my $cobrand = $self->result_source->schema->cobrand;
- my $children = FixMyStreet::MapIt::call('area/children', $body_area->area_id,
- type => $cobrand->area_types_children,
- );
-
- return $children;
+ return $cobrand->fetch_area_children($body_area->area_id);
}
=head2 get_cobrand_handler
@@ -209,6 +211,33 @@ sub get_cobrand_handler {
return FixMyStreet::Cobrand->body_handler($self->areas);
}
+=item
+
+If get_cobrand_handler returns a cobrand, and that cobrand
+has a council_name, use it in preference to the body name.
+
+=cut
+
+sub cobrand_name {
+ my $self = shift;
+
+ # Because TfL covers all the boroughs in London, get_cobrand_handler
+ # may return another London cobrand if it is listed before tfl in
+ # ALLOWED_COBRANDS, because one of this body's area_ids will also
+ # match that cobrand's council_area_id. This leads to odd things like
+ # councils_text_all.html showing a message like "These will be sent to
+ # Bromley Council" when making a report within Westminster on the TfL
+ # cobrand.
+ # If the current body is TfL then we always want to show TfL as the cobrand name.
+ return $self->name if $self->name eq 'TfL' || $self->name eq 'Highways England';
+
+ my $handler = $self->get_cobrand_handler;
+ if ($handler && $handler->can('council_name')) {
+ return $handler->council_name;
+ }
+ return $self->name;
+}
+
sub calculate_average {
my ($self, $threshold) = @_;
$threshold ||= 0;
@@ -224,7 +253,7 @@ sub calculate_average {
'problem.state' => [ FixMyStreet::DB::Result::Problem->visible_states() ],
}, {
select => [
- { extract => "epoch from me.confirmed-problem.confirmed", -as => 'time' },
+ { extract => \"epoch from me.confirmed-problem.confirmed", -as => 'time' },
],
as => [ qw/time/ ],
rows => 100,