diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | docs/_includes/admin-tasks-content.md | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Bodies.pm | 15 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 1 | ||||
-rw-r--r-- | t/app/controller/admin/bodies.t | 11 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 33 | ||||
-rw-r--r-- | templates/web/base/admin/bodies/contact-form.html | 5 |
7 files changed, 48 insertions, 24 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ad53ca547..e5fbb6ea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Move stats from main admin index to stats index. - Speed up dashboard export and report search. - Allow a template to be an initial update on reports. #2973 + - Interface for disabling updates for certain categories. #2991 - Bugfixes - Application user in Docker container can't install packages. #2914 - Look at all categories when sending reports. diff --git a/docs/_includes/admin-tasks-content.md b/docs/_includes/admin-tasks-content.md index 7e3d47efe..a846b73cc 100644 --- a/docs/_includes/admin-tasks-content.md +++ b/docs/_includes/admin-tasks-content.md @@ -560,14 +560,14 @@ and staff users — can filter reports when viewing them on the site. From the Admin menu, click on ‘Categories’. You’ll see a table of existing categories, and below that, a form by which you can create new ones. - Input a title for the category, and the email address to which reports in that category should be forwarded. When creating a category, these are the only fields required. You can also choose a variety of options – whether to automatically hide any reports made in this category, whether to prevent form submission when this -category is selected, or what parent category or categories a particular -category is in. See below for information on <a +category is selected, whether updates are allowed on reports in this category, +or what parent category or categories a particular category is in. See below +for information on <a href="#creating-editing-notices">creating/editing extra notices and questions</a> for a category. diff --git a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm index 6ae068cd9..61b486f02 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm @@ -267,15 +267,12 @@ sub update_contact : Private { $contact->send_method( $c->get_param('send_method') ); # Set flags in extra to the appropriate values - if ( $c->get_param('photo_required') ) { - $contact->set_extra_metadata_if_undefined( photo_required => 1 ); - } else { - $contact->unset_extra_metadata( 'photo_required' ); - } - if ( $c->get_param('open311_protect') ) { - $contact->set_extra_metadata( open311_protect => 1 ); - } else { - $contact->unset_extra_metadata( 'open311_protect' ); + foreach (qw(photo_required open311_protect updates_disallowed)) { + if ( $c->get_param($_) ) { + $contact->set_extra_metadata( $_ => 1 ); + } else { + $contact->unset_extra_metadata($_); + } } if ( my @group = $c->get_param_list('group') ) { @group = grep { $_ } @group; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 695487268..07e781479 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -530,6 +530,7 @@ or not. Default behaviour is disallowed if "closed_updates" metadata is set. sub updates_disallowed { my ($self, $problem) = @_; return 1 if $problem->get_extra_metadata('closed_updates'); + return 1 if $problem->contact && $problem->contact->get_extra_metadata('updates_disallowed'); return 0; } diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t index c73a90da1..7ec7aed75 100644 --- a/t/app/controller/admin/bodies.t +++ b/t/app/controller/admin/bodies.t @@ -261,6 +261,17 @@ subtest 'open311 protection editing' => sub { is $contact->get_extra_metadata('open311_protect'), 1, 'Open311 protect flag set'; }; +subtest 'updates disabling' => sub { + $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); + $mech->submit_form_ok( { with_fields => { + updates_disallowed => 1, + note => 'Disabling updates', + } } ); + $mech->content_contains('Values updated'); + my $contact = $body->contacts->find({ category => 'test category' }); + is $contact->get_extra_metadata('updates_disallowed'), 1, 'Updates disallowed flag set'; +}; + }; # END of override wrap diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 07ee48587..e8ab1cc85 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -22,6 +22,8 @@ my $user2 = $mech->create_user_ok('commenter@example.com', name => 'Commenter'); my $body = $mech->create_body_ok(2504, 'Westminster City Council'); +my $contact = $mech->create_contact_ok( body_id => $body->id, category => 'Other', email => 'other' ); + my $dt = DateTime->new( year => 2011, month => 04, @@ -1893,6 +1895,18 @@ for my $test ( }; } +$mech->log_in_ok( $report->user->email ); + +my %standard_fields = ( + name => $report->user->name, + update => 'update text', + photo1 => '', + photo2 => '', + photo3 => '', + may_show_name => 1, + add_alert => 1, +); + for my $test ( { desc => 'update confirmed without marking as fixed leaves state unchanged', @@ -2094,18 +2108,6 @@ for my $test ( }, ) { subtest $test->{desc} => sub { - $mech->log_in_ok( $report->user->email ); - - my %standard_fields = ( - name => $report->user->name, - update => 'update text', - photo1 => '', - photo2 => '', - photo3 => '', - may_show_name => 1, - add_alert => 1, - ); - my %expected_fields = ( %standard_fields, %{ $test->{expected_form_fields} }, @@ -2178,4 +2180,11 @@ FixMyStreet::override_config { }; }; +subtest 'check disabling of updates per category' => sub { + $contact->set_extra_metadata( updates_disallowed => 1 ); + $contact->update; + $mech->get_ok("/report/$report_id"); + $mech->content_lacks('Provide an update'); +}; + done_testing(); diff --git a/templates/web/base/admin/bodies/contact-form.html b/templates/web/base/admin/bodies/contact-form.html index 35fab4541..ddee35020 100644 --- a/templates/web/base/admin/bodies/contact-form.html +++ b/templates/web/base/admin/bodies/contact-form.html @@ -63,6 +63,11 @@ <textarea id="disabled-message" name="disable_message" class="form-control">[% contact.disable_form_field.description %]</textarea> </p> + <p class="form-check"> + <input type="checkbox" name="updates_disallowed" value="1" id="updates_disallowed" [% ' checked' IF contact.get_extra_metadata('updates_disallowed') %]> + <label for="updates_disallowed">[% loc('Disable updates on reports in this category') %]</label> + </p> + [% IF body.send_method == 'Open311' %] <p class="form-check"> <input type="checkbox" name="open311_protect" value="1" id="open311_protect"[% ' checked' IF contact.get_extra_metadata('open311_protect') %]> |