diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 1 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 27 | ||||
-rw-r--r-- | templates/web/base/report/display.html | 20 | ||||
-rw-r--r-- | templates/web/base/report/update-form.html | 2 |
5 files changed, 42 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b34fb900e..477d9c03f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix display of area/pins on body page when using Bing or TonerLite map. - Do not scan through all problems to show /_dev pages. - Development improvements: + - Cobrand hook for disabling updates on individual problems. - Cobrand hook for disallowing title moderation. #2228 * v2.4 (6th September 2018) diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 4a5b8db5d..5ad21ba48 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -241,6 +241,7 @@ This makes sure we only proceed to processing if we've had the form submitted sub check_form_submitted : Private { my ( $self, $c ) = @_; return if $c->stash->{problem}->get_extra_metadata('closed_updates'); + return if $c->cobrand->call_hook(updates_disallowed => $c->stash->{problem}); return $c->get_param('submit_update') || ''; } diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index aba7340b0..285e6b90f 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -1,3 +1,14 @@ +use strict; +use warnings; + +package FixMyStreet::Cobrand::NoUpdates; + +use parent 'FixMyStreet::Cobrand::FixMyStreet'; + +sub updates_disallowed { 1 } + +package main; + use FixMyStreet::TestMech; use Web::Scraper; use Path::Class; @@ -2150,4 +2161,20 @@ subtest 'check cannot answer other user\'s creator fixed questionnaire' => sub { $mech->content_contains( "I'm afraid we couldn't locate your problem in the database." ) }; +subtest 'updates can be provided' => sub { + $mech->log_out_ok(); + $mech->get( "/report/$report_id" ); + $mech->content_contains("Provide an update"); +}; + +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { 'noupdates' => '.' } ], +}, sub { + subtest 'test cobrand updates_disallowed' => sub { + $mech->log_out_ok(); + $mech->get( "/report/$report_id" ); + $mech->content_lacks("Provide an update"); + }; +}; + done_testing(); diff --git a/templates/web/base/report/display.html b/templates/web/base/report/display.html index eedbc4f85..cb5bf327c 100644 --- a/templates/web/base/report/display.html +++ b/templates/web/base/report/display.html @@ -61,14 +61,18 @@ c.uri_for( '/report/new', { longitude => longitude, latitude => latitude } ) ) %] </p> -[% ELSIF NOT shown_form %] - [% IF two_column_sidebar %] - <button class="btn btn--provide-update js-provide-update hidden-nojs">[% loc('Provide an update') %]</button> - <div class="hidden-js"> - [% END %] - [% INCLUDE 'report/update-form.html' %] - [% IF two_column_sidebar %] - </div> +[% ELSIF NOT shown_form %] + [% UNLESS c.cobrand.updates_disallowed(problem) %] + [% IF two_column_sidebar %] + <button class="btn btn--provide-update js-provide-update hidden-nojs">[% loc('Provide an update') %]</button> + <div class="hidden-js"> + [% END %] + [% INCLUDE 'report/update-form.html' %] + [% IF two_column_sidebar %] + </div> + [% END %] + [% ELSE %] + [% TRY %][% INCLUDE 'report/_updates_disallowed_message.html' %][% CATCH file %][% END %] [% END %] [% END %] diff --git a/templates/web/base/report/update-form.html b/templates/web/base/report/update-form.html index 9276acde9..a68ce117f 100644 --- a/templates/web/base/report/update-form.html +++ b/templates/web/base/report/update-form.html @@ -1,4 +1,4 @@ -[% allow_creation = !c.cobrand.only_authed_can_create || (c.user && c.user.from_body) %] +[% allow_creation = (!c.cobrand.only_authed_can_create || (c.user && c.user.from_body)) AND NOT c.cobrand.updates_disallowed(problem) %] [% RETURN IF NOT allow_creation OR problem.extra.closed_updates %] <div id="update_form"> |