aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-08-20 15:22:37 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-09-13 14:24:58 +0100
commit9e5595755c912dfa8ae020253668b29f48494e23 (patch)
tree3d5e950232df8418088fcf9a713b02e1b30e9fc2
parent847ea6f773ddb5ba921ee1d9f1a0db4799687b1d (diff)
Add cobrand hook for disallowing updates.
Provides a template override for cobrands to show if updates aren't allowed on the problem.
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm1
-rw-r--r--t/app/controller/report_updates.t27
-rw-r--r--templates/web/base/report/display.html20
-rw-r--r--templates/web/base/report/update-form.html2
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">