From 804506834e0ef7c1d6d9ab21dece21a18651295f Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 1 Feb 2017 12:50:22 +0000 Subject: [Oxfordshire] Allow cobrand-specific traffic management options Fixes mysociety/fixmystreetforcouncils#159 --- perllib/FixMyStreet/Cobrand/Default.pm | 7 +++++++ perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 9 +++++++++ perllib/FixMyStreet/DB/Result/Problem.pm | 13 +++++++++++++ t/app/controller/report_inspect.t | 10 ++++++++++ templates/web/base/report/_inspect.html | 5 +++-- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 56e365050..1fdbe9de2 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -1188,4 +1188,11 @@ sub category_extra_hidden { return 0; } +sub traffic_management_options { + return [ + _("Yes"), + _("No"), + ]; +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index dca208e98..e58c7f36b 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -121,4 +121,13 @@ sub contact_email { sub admin_user_domain { 'oxfordshire.gov.uk' } +sub traffic_management_options { + return [ + "Signs and Cones", + "Stop and Go Boards", + "High Speed Roads", + ]; +} + + 1; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index e42e7110a..0092dd8b5 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -1056,4 +1056,17 @@ has duplicates => ( }, ); +has traffic_management_options => ( + is => 'ro', + lazy => 1, + default => sub { + my $self = shift; + my $cobrand = $self->get_cobrand_logged; + if ( $cobrand->can('get_body_handler_for_problem') ) { + $cobrand = $cobrand->get_body_handler_for_problem( $self ); + } + return $cobrand->traffic_management_options; + }, +); + 1; diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 1f11829b7..f092561db 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -186,6 +186,16 @@ FixMyStreet::override_config { $report->discard_changes; is $report->user->get_extra_metadata('reputation'), $reputation-1, "User reputation was decreased"; }; + + subtest "Oxfordshire-specific traffic management options are shown" => sub { + $report->update({ state => 'confirmed' }); + $mech->get_ok("/report/$report_id"); + $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Signs and Cones', state => 'Planned', save_inspected => undef } }); + $report->discard_changes; + is $report->state, 'planned', 'report state changed'; + is $report->get_extra_metadata('traffic_information'), 'Signs and Cones', 'report data changed'; + }; + }; FixMyStreet::override_config { diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html index 43e86cb47..3118a49b6 100644 --- a/templates/web/base/report/_inspect.html +++ b/templates/web/base/report/_inspect.html @@ -108,8 +108,9 @@ [% traffic_info = problem.get_extra_metadata('traffic_information') %]

-- cgit v1.2.3