Skip to content

Commit

Permalink
Include FixMyStreet ID in report metadata.
Browse files Browse the repository at this point in the history
Historically we relied upon the URL for someone getting
the ID of a report, but this is harder on mobile.

Factor together all the _council_sent_info.html templates.
  • Loading branch information
dracos committed May 9, 2023
1 parent a32c71b commit d74dba8
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 147 deletions.
19 changes: 12 additions & 7 deletions perllib/FixMyStreet/DB/Result/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,18 @@ sub defect_types {
return $self->result_source->schema->resultset('DefectType')->for_bodies($self->bodies_str_ids, $self->category);
}

# returns true if the external id is the council's ref, i.e., useful to publish it
# (by way of an example, the Open311 send method returns a useful reference when
# it succeeds, so that is the ref we should show on the problem report page).
# Future: this is installation-dependent so maybe should be using the contact
# data to determine if the external id is public on a council-by-council basis.
# Note: this only makes sense when called on a problem that has been sent!
=head2 can_display_external_id
Returns true if the external id is the council's ref, i.e., useful to publish
it (by way of an example, the Open311 send method returns a useful reference
when it succeeds, so that is the ref we should show on the problem report
page).
Future: this is installation-dependent so maybe should be using the contact
data to determine if the external id is public on a council-by-council basis.
Note: this only makes sense when called on a problem that has been sent!
=cut

sub can_display_external_id {
my $self = shift;
if ( $self->external_id && $self->to_body_named('Lincolnshire|Isle of Wight|East Sussex|Central Bedfordshire|Shropshire|Merton') ) {
Expand All @@ -939,7 +945,6 @@ sub duration_string {
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);
return unless $problem->whensent;
my $s = sprintf(_('Sent to %s %s later'), $body,
Utils::prettify_duration($problem->whensent->epoch - $problem->confirmed->epoch, 'minute')
Expand Down
43 changes: 30 additions & 13 deletions templates/web/base/report/_council_sent_info.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
[% IF c.cobrand.moniker == 'hounslow' %]
[% SET can_display_external_id = problem.external_id AND c.user_exists AND c.user.belongs_to_body(problem.bodies_str) %]
[% ELSE %]
[% SET can_display_external_id = problem.can_display_external_id %]
[% END %]
[% 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 %]
[%- IF duration_clause %]
[%- external_ref_clause = tprintf(loc('Council ref:&nbsp;%s'), problem.external_id) %]
<p class="council_sent_info">
[% duration_clause %][% IF duration_clause %]. [% END %]
<strong>
[%- IF can_display_external_id %]
[%- IF c.cobrand.moniker == 'hounslow' %]
[%- tprintf('Reference:&nbsp;%s', problem.external_id) %].
[%- ELSIF c.cobrand.moniker == 'isleofwight' %]
[%- tprintf('Enquiry ref:&nbsp;%s', problem.external_id) %].
[%- ELSE %]
[%- tprintf(loc('Council ref:&nbsp;%s'), problem.external_id) %].
[%- END %]
[%- ELSE -%]
[%- IF c.cobrand.moniker == 'bathnes' OR c.cobrand.moniker == 'cheshireeast' OR c.cobrand.moniker == 'peterborough' %]
[%- tprintf(loc('Council ref:&nbsp;%s'), problem.id) %].
[%- ELSIF c.cobrand.moniker == 'bexley' %]
[%- tprintf('Report ref:&nbsp;%s', problem.id) %].
[%- ELSIF c.cobrand.moniker == 'tfl' %]
[%- tprintf('TfL ref:&nbsp;FMS%s', problem.id) %].
[%- ELSIF c.cobrand.moniker == 'northamptonshire' %]
[%- IF NOT c.cobrand.is_defect(problem) %]
[% tprintf(loc('ref:&nbsp;%s'), problem.id) %].
[%- END -%]
[%- ELSE %]
[%- external_ref_clause = tprintf(loc('%s ref:&nbsp;%s'), problem.external_body, problem.external_id) %]
[%- tprintf(loc('FixMyStreet ref:&nbsp;%s'), problem.id) %].
[%- END %]
[%- END -%]
[% duration_clause %]
[%- IF external_ref_clause %]
[%- IF duration_clause %]. [% END %]
<strong>[% external_ref_clause %].</strong>
[%- END %]
</p>
[% END %]
</strong>
</p>
17 changes: 0 additions & 17 deletions templates/web/bathnes/report/_council_sent_info.html

This file was deleted.

17 changes: 0 additions & 17 deletions templates/web/bexley/report/_council_sent_info.html

This file was deleted.

17 changes: 0 additions & 17 deletions templates/web/cheshireeast/report/_council_sent_info.html

This file was deleted.

12 changes: 0 additions & 12 deletions templates/web/hounslow/report/_council_sent_info.html

This file was deleted.

17 changes: 0 additions & 17 deletions templates/web/isleofwight/report/_council_sent_info.html

This file was deleted.

13 changes: 0 additions & 13 deletions templates/web/northamptonshire/report/_council_sent_info.html

This file was deleted.

17 changes: 0 additions & 17 deletions templates/web/peterborough/report/_council_sent_info.html

This file was deleted.

17 changes: 0 additions & 17 deletions templates/web/tfl/report/_council_sent_info.html

This file was deleted.

0 comments on commit d74dba8

Please sign in to comment.