diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 7 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Rss.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 9 |
5 files changed, 41 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 46ac10d36..8ec9eeaab 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -385,6 +385,9 @@ sub update_contacts : Private { 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 ( %errors ) { $c->stash->{updated} = _('Please correct the errors below'); diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 355a3f2a9..db3b16dcd 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -270,6 +270,8 @@ sub delete :Local :Args(1) { $p->lastupdate( \'current_timestamp' ); $p->update; + $p->user->update_reputation(-1); + $c->model('DB::AdminLog')->create( { admin_user => $c->user->email, object_type => 'problem', @@ -316,6 +318,7 @@ sub inspect : Private { my $valid = 1; my $update_text; + my $reputation_change = 0; if ($permissions->{report_inspect}) { foreach (qw/detailed_information traffic_information/) { @@ -326,6 +329,7 @@ sub inspect : Private { $update_text = Utils::cleanup_text( $c->get_param('public_update'), { allow_multiline => 1 } ); if ($update_text) { $problem->set_extra_metadata( inspected => 1 ); + $reputation_change = 1; } else { $valid = 0; $c->stash->{errors} ||= []; @@ -371,6 +375,9 @@ sub inspect : Private { } if ($valid) { + if ( $reputation_change != 0 ) { + $problem->user->update_reputation($reputation_change); + } $problem->update; if ( defined($update_text) ) { $problem->add_to_comments( { diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm index 183b233a8..28f1aba43 100755 --- a/perllib/FixMyStreet/App/Controller/Rss.pm +++ b/perllib/FixMyStreet/App/Controller/Rss.pm @@ -207,6 +207,7 @@ sub generate : Private { $out =~ s{(<link>.*?</link>)}{$1<uri>$uri</uri>}; $c->response->header('Content-Type' => 'application/xml; charset=utf-8'); + $c->response->header('Access-Control-Allow-Origin' => '*'); $c->response->body( $out ); } diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 2a2d0d5e3..8d42d5926 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -26,20 +26,22 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "password", { data_type => "text", default_value => "", is_nullable => 0 }, - "flagged", - { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "from_body", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "flagged", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "title", { data_type => "text", is_nullable => 1 }, - "facebook_id", - { data_type => "bigint", is_nullable => 1 }, "twitter_id", { data_type => "bigint", is_nullable => 1 }, + "facebook_id", + { data_type => "bigint", is_nullable => 1 }, "is_superuser", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "area_id", { data_type => "integer", is_nullable => 1 }, + "extra", + { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->add_unique_constraint("users_email_key", ["email"]); @@ -100,11 +102,17 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-08-03 13:52:28 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SX8BS91mWHoOm2oWdNth1w +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-16 14:22:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7wfF1VnZax2QTXCIPXr+vg + +__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); +__PACKAGE__->rabx_column('extra'); use Moo; use mySociety::EmailUtil; +use namespace::clean -except => [ 'meta' ]; + +with 'FixMyStreet::Roles::Extra'; __PACKAGE__->many_to_many( planned_reports => 'user_planned_reports', 'report' ); @@ -370,4 +378,12 @@ sub is_planned_report { return $self->active_planned_reports->find({ id => $problem->id }); } +sub update_reputation { + my ( $self, $change ) = @_; + + my $reputation = $self->get_extra_metadata('reputation') || 0; + $self->set_extra_metadata( reputation => $reputation + $change); + $self->update; +} + 1; diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index 8d3b2ddbc..7d614bc30 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -145,9 +145,16 @@ sub send(;$) { my $inspection_required = $sender_info->{contact}->get_extra_metadata('inspection_required') if $sender_info->{contact}; 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->get_extra_metadata('inspected') || - $row->user->has_permission_to( trusted => $row->bodies_str_ids ) + $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; |