diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-11-20 19:13:52 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2019-12-09 12:50:07 +0000 |
commit | a729f2b9b27af55b6a1e355febd52ac48c425853 (patch) | |
tree | 001ffd319b25ea21dd1cfda258963db3e43349d7 /perllib/FixMyStreet | |
parent | cae638745b1c0777094705032276479dcc1137f4 (diff) |
[fixmystreet.com] Limit TfL cobrand report display
On fixmystreet.com, you cannot view reports made on the TfL cobrand,
apart from on reporting seeing pins labelled with the report's category,
linking through to the TfL cobrand.
Output the pin's base URL if different from normal, so e.g. app can link
appropriately.
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 19 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 2 |
3 files changed, 27 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 4dbe0db42..cbe91ed9e 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -824,7 +824,12 @@ sub ajax : Private { my @pins = map { my $p = $_; # lat, lon, 'colour', ID, title, type/size, draggable - [ $p->{latitude}, $p->{longitude}, $p->{colour}, $p->{id}, $p->{title}, '', JSON->false ] + my $parts = [ $p->{latitude}, $p->{longitude}, $p->{colour}, $p->{id}, $p->{title}, '', JSON->false ]; + # Some reports may only be visible on a specific cobrand on this FMS site. + # If that's the case, include the base URL for the pin's cobrand here so + # the app can link to the right place. + push @$parts, $p->{base_url} if $p->{base_url}; + $parts; } @{$c->stash->{pins}}; my $list_html = $c->render_fragment($template); diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index 26638d41c..03bc0c82b 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -9,6 +9,13 @@ use constant COUNCIL_ID_ISLEOFWIGHT => 2636; sub on_map_default_status { return 'open'; } +# Show TfL pins as grey +sub pin_colour { + my ( $self, $p, $context ) = @_; + return 'grey' if $p->to_body_named('TfL'); + return $self->next::method($p, $context); +} + # Special extra sub path_to_web_templates { my $self = shift; @@ -28,6 +35,18 @@ sub restriction { return {}; } +# FixMyStreet needs to not show TfL reports... +sub problems_restriction { + my ($self, $rs) = @_; + my $table = ref $rs eq 'FixMyStreet::DB::ResultSet::Nearby' ? 'problem' : 'me'; + return $rs->search({ "$table.cobrand" => { '!=' => 'tfl' } }); +} + +sub relative_url_for_report { + my ( $self, $report ) = @_; + return $report->cobrand eq 'tfl' ? FixMyStreet::Cobrand::TfL->base_url : ""; +} + sub munge_around_category_where { my ($self, $where) = @_; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 28703c416..a188d9c2b 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -340,6 +340,7 @@ around service => sub { sub title_safe { my $self = shift; return _('Awaiting moderation') if $self->cobrand eq 'zurich' && $self->state eq 'submitted'; + return sprintf("%s problem", $self->category) if $self->cobrand eq 'tfl' && $self->result_source->schema->cobrand->moniker ne 'tfl'; return $self->title; } @@ -1039,6 +1040,7 @@ sub pin_data { problem => $self, draggable => $opts{draggable}, type => $opts{type}, + base_url => $c->cobrand->relative_url_for_report($self), } }; |