diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Bodies.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Users.pm | 29 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 16 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 19 | ||||
-rw-r--r-- | t/app/controller/admin/users.t | 1 | ||||
-rw-r--r-- | t/app/controller/report_inspect.t | 34 | ||||
-rw-r--r-- | t/app/sendreport/inspection_required.t | 85 | ||||
-rw-r--r-- | templates/web/base/admin/bodies/contact-form.html | 15 | ||||
-rw-r--r-- | templates/web/base/admin/users/form.html | 23 | ||||
-rw-r--r-- | templates/web/oxfordshire/admin/user-form-extra-fields.html | 9 |
13 files changed, 0 insertions, 264 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm index 165fdc783..098c29ad4 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm @@ -269,14 +269,6 @@ sub update_contact : Private { } else { $contact->unset_extra_metadata( 'photo_required' ); } - if ( $c->get_param('inspection_required') ) { - $contact->set_extra_metadata( inspection_required => 1 ); - } else { - $contact->unset_extra_metadata( 'inspection_required' ); - } - if ( $c->get_param('reputation_threshold') ) { - $contact->set_extra_metadata( reputation_threshold => int($c->get_param('reputation_threshold')) ); - } if ( my @group = $c->get_param_list('group') ) { @group = grep { $_ } @group; if (scalar @group == 0) { diff --git a/perllib/FixMyStreet/App/Controller/Admin/Users.pm b/perllib/FixMyStreet/App/Controller/Admin/Users.pm index fd18caf21..0d7c23fff 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Users.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Users.pm @@ -371,35 +371,6 @@ sub edit : Path : Args(1) { $user->area_ids( @area_ids ? \@area_ids : undef ); } - # Handle 'trusted' flag(s) - my @trusted_bodies = $c->get_param_list('trusted_bodies'); - if ( $c->user->is_superuser ) { - $user->user_body_permissions->search({ - body_id => { -not_in => \@trusted_bodies }, - permission_type => 'trusted', - })->delete; - foreach my $body_id (@trusted_bodies) { - $user->user_body_permissions->find_or_create({ - body_id => $body_id, - permission_type => 'trusted', - }); - } - } elsif ( $c->user->from_body ) { - my %trusted = map { $_ => 1 } @trusted_bodies; - my $body_id = $c->user->from_body->id; - if ( $trusted{$body_id} ) { - $user->user_body_permissions->find_or_create({ - body_id => $body_id, - permission_type => 'trusted', - }); - } else { - $user->user_body_permissions->search({ - body_id => $body_id, - permission_type => 'trusted', - })->delete; - } - } - # Update the categories this user operates in if ( $user->from_body ) { $c->stash->{body} = $user->from_body; diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 692379de6..89350b1cb 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -356,8 +356,6 @@ sub delete :Chained('id') :Args(0) { $p->lastupdate( \'current_timestamp' ); $p->update; - $p->user->update_reputation(-1); - $c->model('DB::AdminLog')->create( { user => $c->user->obj, admin_user => $c->user->from_body->name, @@ -408,7 +406,6 @@ sub inspect : Private { my $valid = 1; my $update_text = ''; - my $reputation_change = 0; my %update_params = (); if ($permissions->{report_inspect}) { @@ -463,8 +460,6 @@ sub inspect : Private { $update_params{problem_state} = $problem->state; my $state = $problem->state; - $reputation_change = 1 if $c->cobrand->reputation_increment_states->{$state}; - $reputation_change = -1 if $c->cobrand->reputation_decrement_states->{$state}; # If an inspector has changed the state, subscribe them to # updates @@ -518,9 +513,6 @@ sub inspect : Private { $c->cobrand->call_hook(report_inspect_update_extra => $problem); if ($valid) { - if ( $reputation_change != 0 ) { - $problem->user->update_reputation($reputation_change); - } $problem->lastupdate( \'current_timestamp' ); $problem->update; if ($update_text || %update_params) { diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index d2929dcc0..620183078 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -748,12 +748,6 @@ sub available_permissions { contribute_as_body => _("Create reports/updates as the council"), default_to_body => _("Default to creating reports/updates as the council"), view_body_contribute_details => _("See user detail for reports created as the council"), - - # NB this permission is special in that it can be assigned to users - # without their from_body being set. It's included here for - # reference, but left commented out because it's not assigned in the - # same way as other permissions. - # trusted => _("Trusted to make reports that don't need to be inspected"), }, _("Users") => { user_edit => _("Edit users' details/search for their reports"), @@ -1227,16 +1221,6 @@ sub category_extra_hidden { return 0; } -=item reputation_increment_states/reputation_decrement_states - -Get a hashref of states that cause the reporting user's reputation to be -incremented/decremented, if a report is changed to this state upon inspection. - -=cut - -sub reputation_increment_states { {} }; -sub reputation_decrement_states { {} }; - sub traffic_management_options { return [ _("Yes"), diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index f99cdf84d..6f6284c7a 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -172,12 +172,6 @@ sub admin_pages { return $pages; } -sub reputation_increment_states { - return { - 'action scheduled' => 1, - }; -} - sub user_extra_fields { return [ 'initials' ]; } diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 85fdc790b..c5824af36 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -438,9 +438,6 @@ sub has_permission_to { my $cobrand = $self->result_source->schema->cobrand; my $cobrand_perms = $cobrand->available_permissions; my %available = map { %$_ } values %$cobrand_perms; - # The 'trusted' permission is never set in the cobrand's - # available_permissions (see note there in Default.pm) so include it here. - $available{trusted} = 1; return 0 unless $available{$permission_type}; return 1 if $self->is_superuser; @@ -600,14 +597,6 @@ sub is_planned_report { return scalar grep { $_->report_id == $id } @{$self->active_user_planned_reports}; } -sub update_reputation { - my ( $self, $change ) = @_; - - my $reputation = $self->get_extra_metadata('reputation') || 0; - $self->set_extra_metadata( reputation => $reputation + $change); - $self->update; -} - has categories => ( is => 'ro', lazy => 1, diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index 59de86db1..9725f1781 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -148,25 +148,6 @@ sub send(;$) { } $reporters{ $sender } ||= $sender->new(); - my $inspection_required = $sender_info->{contact} - ? $sender_info->{contact}->get_extra_metadata('inspection_required') - : undef; - if ( $inspection_required ) { - my $reputation_threshold = $sender_info->{contact}->get_extra_metadata('reputation_threshold') || 0; - my $reputation_threshold_met = 0; - if ( $reputation_threshold > 0 ) { - my $user_reputation = $row->user->get_extra_metadata('reputation') || 0; - $reputation_threshold_met = $user_reputation >= $reputation_threshold; - } - unless ( - $row->user->has_permission_to( trusted => $row->bodies_str_ids ) || - $reputation_threshold_met - ) { - $skip = 1; - debug_print("skipped because not yet inspected", $row->id) if $debug_mode; - } - } - if ( $reporters{ $sender }->should_skip( $row, $debug_mode ) ) { $skip = 1; debug_print("skipped by sender " . $sender_info->{method} . " (might be due to previous failed attempts?)", $row->id) if $debug_mode; diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t index 7361ab619..17256a214 100644 --- a/t/app/controller/admin/users.t +++ b/t/app/controller/admin/users.t @@ -249,7 +249,6 @@ my %default_perms = ( "permissions[template_edit]" => undef, "permissions[responsepriority_edit]" => undef, "permissions[category_edit]" => undef, - trusted_bodies => undef, ); # Start this section with user having no name diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index b6498e840..61fa821b2 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -132,7 +132,6 @@ FixMyStreet::override_config { $user->user_body_permissions->create({ body => $oxon, permission_type => 'planned_reports' }); $report->state('confirmed'); $report->update; - my $reputation = $report->user->get_extra_metadata("reputation"); $mech->get_ok("/report/$report_id"); $mech->submit_form_ok({ button => 'save', with_fields => { public_update => "This is a public update.", include_update => "1", @@ -145,7 +144,6 @@ FixMyStreet::override_config { $report->discard_changes; my $comment = ($report->comments( undef, { order_by => { -desc => 'id' } } )->all)[1]->text; is $comment, "This is a public update.", 'Update was created'; - is $report->user->get_extra_metadata('reputation'), $reputation, "User reputation wasn't changed"; $mech->get_ok("/report/$report_id"); my $meta = $mech->extract_update_metas; like $meta->[0], qr/State changed to: Action scheduled/, 'First update mentions action scheduled'; @@ -583,38 +581,6 @@ FixMyStreet::override_config { return $perms; }); - subtest "test negative reputation" => sub { - my $reputation = $report->user->get_extra_metadata("reputation") || 0; - - $mech->get_ok("/report/$report_id"); - $mech->submit_form( button => 'remove_from_site' ); - - $report->discard_changes; - is $report->user->get_extra_metadata('reputation'), $reputation-1, "User reputation was decreased"; - $report->update({ state => 'confirmed' }); - }; - - subtest "test positive reputation" => sub { - $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' }); - $report->update; - $report->inspection_log_entry->delete if $report->inspection_log_entry; - my $reputation = $report->user->get_extra_metadata("reputation") || 0; - $mech->get_ok("/report/$report_id"); - $mech->submit_form_ok({ button => 'save', with_fields => { - state => 'in progress', include_update => undef, - } }); - $report->discard_changes; - - $mech->submit_form_ok({ button => 'save', with_fields => { - state => 'action scheduled', include_update => undef, - } }); - $report->discard_changes; - is $report->user->get_extra_metadata('reputation'), $reputation+1, "User reputation was increased"; - - $mech->submit_form_ok({ button => 'save', with_fields => { - state => 'action scheduled', include_update => undef, - } }); - }; subtest "Oxfordshire-specific traffic management options are shown" => sub { $report->update({ state => 'confirmed' }); diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t deleted file mode 100644 index 5eff516f5..000000000 --- a/t/app/sendreport/inspection_required.t +++ /dev/null @@ -1,85 +0,0 @@ -use FixMyStreet; -use FixMyStreet::DB; -use FixMyStreet::TestMech; -use FixMyStreet::Script::Reports; - -ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); - -my $user = $mech->create_user_ok( 'user@example.com' ); - -my $body = $mech->create_body_ok( 2237, 'Oxfordshire County Council'); -# $body->update({ send_method => 'Email' }); - -my $contact = $mech->create_contact_ok( - body_id => $body->id, - category => 'Pothole', - email => 'test@example.org', -); -$contact->set_extra_metadata(inspection_required => 1); -$contact->update; - -my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', { - cobrand => 'oxfordshire', - category => $contact->category, - user => $user, -}); -my $report = $reports[0]; - -subtest "Report isn't sent if uninspected" => sub { - $mech->clear_emails_ok; - - FixMyStreet::Script::Reports::send(); - - $mech->email_count_is( 0 ); - is $report->whensent, undef, "Report hasn't been sent"; -}; - -subtest 'Uninspected report is sent when made by trusted user' => sub { - $mech->clear_emails_ok; - $report->whensent( undef ); - $report->update; - - $user->user_body_permissions->find_or_create({ - body => $body, - permission_type => 'trusted', - }); - ok $user->has_permission_to('trusted', $report->bodies_str_ids), 'User can make trusted reports'; - - FixMyStreet::Script::Reports::send(); - - $report->discard_changes; - $mech->email_count_is( 1 ); - ok $report->whensent, 'Report marked as sent'; -}; - -subtest "Uninspected report isn't sent when user rep is too low" => sub { - $mech->clear_emails_ok; - $report->whensent( undef ); - $report->update; - - $user->user_body_permissions->delete; - $user->set_extra_metadata(reputation => 15); - $user->update; - - $contact->set_extra_metadata(reputation_threshold => 20); - $contact->update; - - FixMyStreet::Script::Reports::send(); - - $report->discard_changes; - $mech->email_count_is( 0 ); - is $report->whensent, undef, "Report hasn't been sent"; -}; - -subtest 'Uninspected report is sent when user rep is high enough' => sub { - $user->set_extra_metadata(reputation => 21); - $user->update; - - FixMyStreet::Script::Reports::send(); - - $report->discard_changes; - $mech->email_count_is( 1 ); - ok $report->whensent, 'Report marked as sent'; -}; - -done_testing(); diff --git a/templates/web/base/admin/bodies/contact-form.html b/templates/web/base/admin/bodies/contact-form.html index ba47327cd..921cb1380 100644 --- a/templates/web/base/admin/bodies/contact-form.html +++ b/templates/web/base/admin/bodies/contact-form.html @@ -58,21 +58,6 @@ <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="inspection_required" value="1" id="inspection_required" data-toggle-visibility="#js-inspection-reputation-box" [% 'checked' IF contact.get_extra_metadata('inspection_required') %]> - <label for="inspection_required">[% loc('Reports in this category must be inspected before being sent') %]</label> - </p> - - <p class="form-group form-group--indented [% 'hidden-js' IF NOT contact.get_extra_metadata('inspection_required') %]" id="js-inspection-reputation-box"> - <label for="reputation_threshold">[% loc('Reputation threshold') %]</label> - <span class="form-hint" id="reputation_threshold_hint"> - [% loc("Reports will automatically be sent without needing to be inspected if the user's <strong>reputation</strong> is at or above this value. Set to <strong>0</strong> if all reports must be inspected regardless.") %] - </span> - <input type="text" class="form-control" name="reputation_threshold" id="reputation_threshold" - value="[% contact.get_extra_metadata('reputation_threshold') | html %]" size="30" - aria-describedby="reputation_threshold_hint"> - </p> - [% IF body.can_be_devolved %] <div class="admin-hint"> <p> diff --git a/templates/web/base/admin/users/form.html b/templates/web/base/admin/users/form.html index c9cc6463b..f141dc02c 100644 --- a/templates/web/base/admin/users/form.html +++ b/templates/web/base/admin/users/form.html @@ -116,29 +116,6 @@ </label> </li> - [% UNLESS user.is_superuser %] - <li> - <div class="admin-hint"> - <p> - [% loc("Reports made by trusted users will be sent to the responsible body without being inspected first.") %] - </p> - </div> - [% IF c.user.is_superuser %] - <label for="trusted_bodies">[% loc('Trusted by bodies:') %]</label> - <select class="form-control js-multiple" id='trusted_bodies' name='trusted_bodies' multiple> - [% FOR body IN bodies %] - <option value="[% body.id %]"[% ' selected' IF user.has_permission_to('trusted', body.id) %]>[% body.name %]</option> - [% END %] - </select> - [% ELSE %] - <label> - [% loc('Trusted:') %] - <input type="checkbox" id="trusted_bodies" name="trusted_bodies" value="[% c.user.from_body.id %]" [% 'checked' IF user.has_permission_to('trusted', c.user.from_body.id) %]> - </label> - [% END %] - </li> - [% END %] - [% IF c.user.is_superuser %] <li> <div class="admin-hint"> diff --git a/templates/web/oxfordshire/admin/user-form-extra-fields.html b/templates/web/oxfordshire/admin/user-form-extra-fields.html index 4109a3075..c7697fa35 100644 --- a/templates/web/oxfordshire/admin/user-form-extra-fields.html +++ b/templates/web/oxfordshire/admin/user-form-extra-fields.html @@ -1,15 +1,6 @@ <li> <div class="admin-hint"> <p> - [% loc("Reports from users with high enough reputation will be sent immediately without requiring inspection. Each category's threshold can be managed on its edit page. Users earn reputation when a report they have made is marked as inspected by inspectors.") %] - </p> - </div> - [% loc('Reputation:') %] [% user.get_extra_metadata('reputation') %] -</li> - -<li> - <div class="admin-hint"> - <p> [% loc( "The user's initials are used when sending inspections to Exor. Only inspectors need to have this field filled in.") |