aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm23
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm4
-rw-r--r--templates/web/base/around/lookup_by_ref.html18
4 files changed, 56 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 82a7a9e76..c4feca8b6 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -38,6 +38,11 @@ sub index : Path : Args(0) {
# Check if we have a partial report
my $partial_report = $c->forward('load_partial');
+ # Check if the user is searching for a report by ID
+ if ( $c->get_param('pc') && $c->get_param('pc') =~ $c->cobrand->lookup_by_ref_regex ) {
+ $c->go('lookup_by_ref', [ $1 ]);
+ }
+
# Try to create a location for whatever we have
my $ret = $c->forward('/location/determine_location_from_coords')
|| $c->forward('/location/determine_location_from_pc');
@@ -385,6 +390,24 @@ sub _geocode : Private {
}
+sub lookup_by_ref : Private {
+ my ( $self, $c, $ref ) = @_;
+
+ my $problems = $c->cobrand->problems->search([
+ id => $ref,
+ external_id => $ref
+ ]);
+
+ if ( $problems->count == 0) {
+ $c->detach( '/page_error_404_not_found', [] );
+ } elsif ( $problems->count == 1 ) {
+ $c->res->redirect( $c->uri_for( '/report', $problems->first->id ) );
+ } else {
+ $c->stash->{ref} = $ref;
+ $c->stash->{matching_reports} = [ $problems->all ];
+ }
+}
+
__PACKAGE__->meta->make_immutable;
1;
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 043d0b8e6..ee110a18b 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -1135,4 +1135,15 @@ sub contact_details_data {
return ()
}
+=head2 lookup_by_ref_regex
+
+Returns a regex to match postcode form input against to determine if a lookup
+by id should be done.
+
+=cut
+
+sub lookup_by_ref_regex {
+ return qr/^\s*ref:\s*(\d+)\s*$/;
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index e60b673b4..206f4bb1e 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -392,5 +392,9 @@ sub link_to_council_cobrand {
}
}
+sub lookup_by_ref_regex {
+ return qr/^\s*(\d+)\s*$/;
+}
+
1;
diff --git a/templates/web/base/around/lookup_by_ref.html b/templates/web/base/around/lookup_by_ref.html
new file mode 100644
index 000000000..aded05638
--- /dev/null
+++ b/templates/web/base/around/lookup_by_ref.html
@@ -0,0 +1,18 @@
+[% pre_container_extra = INCLUDE 'around/postcode_form.html', pc = ref %]
+[% INCLUDE 'header.html', title = loc('Reporting a problem'), bodyclass = 'frontpage fullwidthpage' %]
+
+<div class="tablewrapper">
+ <p>[% loc('We found more than one match for that problem reference:') %]</p>
+ <ul class="pc_alternatives">
+ [% FOREACH report IN matching_reports %]
+ <li>
+ <a href="/report/[% report.id | uri %]">
+ [% report.title | html %]
+ ([% IF report.id == ref %]ref. [% report.id | html %][% ELSE %]external ref. [% report.external_id | html %][% END %])
+ </a>
+ </li>
+ [% END %]
+ </ul>
+</div>
+
+[% INCLUDE 'footer.html' %]