diff options
-rwxr-xr-x | bin/send-reports | 1 | ||||
-rw-r--r-- | db/schema.sql | 5 | ||||
-rw-r--r-- | db/schema_0015-add_send_method_used_column_to_problem.sql | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 26 | ||||
-rw-r--r-- | templates/web/default/report/_main.html | 5 | ||||
-rw-r--r-- | templates/web/fixmystreet/report/_main.html | 6 |
6 files changed, 38 insertions, 11 deletions
diff --git a/bin/send-reports b/bin/send-reports index 5842e1694..77c7b1a10 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -546,6 +546,7 @@ sub post_barnet_message { if (my $barnet_id = $result->get_EV_ORDER_NO()) { $problem->external_id( $barnet_id ); $problem->external_body( 'Barnet Borough Council' ); # better to use $problem->body()? + $problem->send_method_used('barnet'); $return = 0; } else { $err_msg = "Failed (problem id $h{id}): service returned no external id"; diff --git a/db/schema.sql b/db/schema.sql index 5824b2d6d..e1205099d 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -194,7 +194,10 @@ create table problem ( -- logging sending failures (used by webservices) send_fail_count integer not null default 0, send_fail_reason text, - send_fail_timestamp timestamp + send_fail_timestamp timestamp, + + -- record send_method used, which can be used to infer usefulness of external_id + send_method_used text ); create index problem_state_latitude_longitude_idx on problem(state, latitude, longitude); create index problem_user_id_idx on problem ( user_id ); diff --git a/db/schema_0015-add_send_method_used_column_to_problem.sql b/db/schema_0015-add_send_method_used_column_to_problem.sql new file mode 100644 index 000000000..0c6e0851d --- /dev/null +++ b/db/schema_0015-add_send_method_used_column_to_problem.sql @@ -0,0 +1,6 @@ +begin; + +ALTER table problem + ADD column send_method_used text; + +commit; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 4b738b66c..192e539bd 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -85,11 +85,13 @@ __PACKAGE__->add_columns( "geocode", { data_type => "bytea", is_nullable => 1 }, "send_fail_count", - { data_type => "integer", is_nullable => 1 }, + { data_type => "integer", default_value => 0, is_nullable => 0 }, "send_fail_reason", { data_type => "text", is_nullable => 1 }, "send_fail_timestamp", { data_type => "timestamp", is_nullable => 1 }, + "send_method_used", + { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->has_many( @@ -112,8 +114,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-16 10:08:56 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VODeZlWk8l/+IzBBlRNV0A +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-05-03 16:05:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EvwI91Ot7SioQWqwnXRTBQ # Add fake relationship to stored procedure table __PACKAGE__->has_one( @@ -568,11 +570,25 @@ sub body { return $body; } +# returns true if the external id is the council's ref, i.e., useful to publish it +# (by way of an example, the barnet 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! +sub can_display_external_id { + my $self = shift; + if ($self->external_id && $self->send_method_used eq 'barnet') { + return 1; + } + return 0; +} + # TODO Some/much of this could be moved to the template # either: # "sent to council 3 mins later" -# "council ref: XYZ" +# "[Council name] ref: XYZ" # or # "sent to council 3 mins later, their ref: XYZ" # @@ -584,7 +600,7 @@ sub processed_summary_string { if ($problem->whensent) { $duration_clause = $problem->duration_string($c) } - if ($problem->external_id) { + if ($problem->can_display_external_id) { if ($duration_clause) { $external_ref_clause = sprintf(_('their ref: %s'), $problem->external_id); } else { diff --git a/templates/web/default/report/_main.html b/templates/web/default/report/_main.html index 552be17e6..3a9e60e7b 100644 --- a/templates/web/default/report/_main.html +++ b/templates/web/default/report/_main.html @@ -2,12 +2,11 @@ <p><em>[% problem.meta_line(c) | html %] [% IF problem.council %] - [% IF problem.whensent || problem.external_id %] + [% IF problem.whensent || problem.can_display_external_id %] <small class="council_sent_info"><br> [% problem.processed_summary_string(c) %] </small> - [% END %] - + [% END %] [% ELSE %] <br><small>[% loc('Not reported to council') %]</small> [% END %] diff --git a/templates/web/fixmystreet/report/_main.html b/templates/web/fixmystreet/report/_main.html index 762aa10f7..7ceb1f6a5 100644 --- a/templates/web/fixmystreet/report/_main.html +++ b/templates/web/fixmystreet/report/_main.html @@ -4,8 +4,10 @@ <p><em> [% problem.meta_line(c) | html %] [% IF problem.council %] - [% IF problem.whensent %] - <small class="council_sent_info"><br>[% problem.duration_string(c) %]</small> + [% IF problem.whensent || problem.can_display_external_id %] + <small class="council_sent_info"><br> + [% problem.processed_summary_string(c) %] + </small> [% END %] [% ELSE %] <br><small>[% loc('Not reported to council') %]</small> |