From 2abd85a6d9151f95c82656df9e6b8220e381ca03 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 1 Dec 2016 18:25:24 +0000 Subject: Add offline storing of inspect forms. This allows the inspect form to be submitted when offline, with the data saved in localStorage, the number of saved forms shown in the banner, and the forms to be uploaded when back online. It copes if you go back to a report after having submitted the form, and if the back-online submission fails due to CSRF failure, retrying once with a new token. --- perllib/FixMyStreet/App/Controller/Report.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index f7ccddc70..481bc4ab8 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -385,10 +385,14 @@ sub inspect : Private { $problem->lastupdate( \'current_timestamp' ); $problem->update; if ( defined($update_text) ) { + my $timestamp = \'current_timestamp'; + if (my $saved_at = $c->get_param('saved_at')) { + $timestamp = DateTime->from_epoch( epoch => $saved_at ); + } $problem->add_to_comments( { text => $update_text, - created => \'current_timestamp', - confirmed => \'current_timestamp', + created => $timestamp, + confirmed => $timestamp, user_id => $c->user->id, name => $c->user->from_body->name, state => 'confirmed', -- cgit v1.2.3 From fd55ac237e453139f4e8feba5db2fe6e55987023 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 24 Jan 2017 09:20:35 +0000 Subject: Redirect to shortlist if user has shortlist perms. Assume that if they inspect and save a report, they want to go back to their shortlist. --- perllib/FixMyStreet/App/Controller/Report.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 3c251a5cb..175db4a19 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -433,6 +433,12 @@ sub inspect : Private { } else { $redirect_uri = $c->uri_for( $problem->url ); } + + # Or if inspector, redirect back to shortlist + if ($c->user->has_body_permission_to('planned_reports')) { + $redirect_uri = $c->uri_for_action('my/planned'); + } + $c->log->debug( "Redirecting to: " . $redirect_uri ); $c->res->redirect( $redirect_uri ); } -- cgit v1.2.3 From 71e4186cefa356f240870cd5edf0e15b27e5e044 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 18 Jan 2017 14:32:19 +0000 Subject: =?UTF-8?q?Clarify=20=E2=80=98inspected=E2=80=99=20behaviour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A report is now considered 'inspected' if its state was changed by an inspector. Additionally, an AdminLog entry is created so the time of inspection and inspector can be recorded. --- perllib/FixMyStreet/App/Controller/Report.pm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 175db4a19..ad26ecf84 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -343,12 +343,9 @@ sub inspect : Private { $problem->set_extra_metadata( $_ => $c->get_param($_) ); } - if ( $c->get_param('save_inspected') ) { + if ( $c->get_param('include_update') ) { $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 { + if (!$update_text) { $valid = 0; $c->stash->{errors} ||= []; push @{ $c->stash->{errors} }, _('Please provide a public update for this report.'); @@ -374,6 +371,14 @@ sub inspect : Private { } if ( $problem->state ne $old_state ) { $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'state_change' ] ); + + # If the state has been changed by an inspector, consider the + # report to be inspected. + unless ($problem->get_extra_metadata('inspected')) { + $problem->set_extra_metadata( inspected => 1 ); + $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'inspected' ] ); + $reputation_change = 1; + } } } -- cgit v1.2.3 From 0b1bc26366811481b322c322f2414514bb7c2166 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 1 Feb 2017 11:40:38 +0000 Subject: Allow cobrands to control which states affect reputation Rather than assigning +1 to a user's reputation every time a report is inspected, this allows cobrands to specify which states should increment or decrement the reputation value when a report is inspected. The default behaviour is for reputation to never be changed, but the Oxfordshire cobrand will increment the reputation when a report is marked as 'action scheduled'. For mysociety/fixmystreetforcouncils#119 --- perllib/FixMyStreet/App/Controller/Report.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index ad26ecf84..5c34630c4 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -377,7 +377,9 @@ sub inspect : Private { unless ($problem->get_extra_metadata('inspected')) { $problem->set_extra_metadata( inspected => 1 ); $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'inspected' ] ); - $reputation_change = 1; + my $state = $problem->state; + $reputation_change = 1 if $c->cobrand->reputation_increment_states->{$state}; + $reputation_change = -1 if $c->cobrand->reputation_decrement_states->{$state}; } } } -- cgit v1.2.3 From 4d44ea5530a7dc25122e5135c19d89b4cebc5f40 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 7 Dec 2016 11:39:59 +0000 Subject: [Oxfordshire] Add Exor RDI file download feature The RDI file format encapsulates information about inspections that have taken place, and can be uploaded into Exor to create defects in bulk. This commit adds a page to the Oxfordshire cobrand's admin allowing RDI files to be generated and downloaded from FMS. For mysociety/fixmystreetforcouncils#127 --- perllib/FixMyStreet/App/Controller/Report.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 5c34630c4..35d7afd5b 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -339,7 +339,7 @@ sub inspect : Private { my %update_params = (); if ($permissions->{report_inspect}) { - foreach (qw/detailed_information traffic_information duplicate_of/) { + foreach (qw/detailed_information traffic_information duplicate_of defect_type/) { $problem->set_extra_metadata( $_ => $c->get_param($_) ); } -- cgit v1.2.3 From 57e5cd72ed7fe2f8b9c72a1390a7ad37fd5cfcc2 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 3 Mar 2017 18:06:20 +0000 Subject: Allow superuser to leave update when inspecting. --- perllib/FixMyStreet/App/Controller/Report.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 35d7afd5b..7cd9d32a0 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -419,12 +419,13 @@ sub inspect : Private { if (my $saved_at = $c->get_param('saved_at')) { $timestamp = DateTime->from_epoch( epoch => $saved_at ); } + my $name = $c->user->from_body ? $c->user->from_body->name : $c->user->name; $problem->add_to_comments( { text => $update_text, created => $timestamp, confirmed => $timestamp, user_id => $c->user->id, - name => $c->user->from_body->name, + name => $name, state => 'confirmed', mark_fixed => 0, anonymous => 0, -- cgit v1.2.3 From ecb6c0373a36b182fbc671602946805d64dcf679 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 7 Mar 2017 16:51:05 +0000 Subject: Store user object when deleting report. --- perllib/FixMyStreet/App/Controller/Report.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 7cd9d32a0..27f4393bb 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -275,7 +275,8 @@ sub delete :Local :Args(1) { $p->user->update_reputation(-1); $c->model('DB::AdminLog')->create( { - admin_user => $c->user->email, + user => $c->user, + admin_user => $c->user->from_body->name, object_type => 'problem', action => 'state_change', object_id => $id, -- cgit v1.2.3 From 02fcb1606bc2b739fdc798e5ca06f2ed1b6bf6ea Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 17 Mar 2017 22:25:08 +0000 Subject: Fix warning, use correct user object in delete log --- perllib/FixMyStreet/App/Controller/Report.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 27f4393bb..1c2e98bd4 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -275,7 +275,7 @@ sub delete :Local :Args(1) { $p->user->update_reputation(-1); $c->model('DB::AdminLog')->create( { - user => $c->user, + user => $c->user->obj, admin_user => $c->user->from_body->name, object_type => 'problem', action => 'state_change', -- cgit v1.2.3 From 3f21a9742d89c3e4fda47a0be6ec2a17f802c99a Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Mon, 13 Feb 2017 15:13:12 +0000 Subject: Add customisable defect types. Problems can have an associated defect type, that can be assigned during an inspection. Include an admin interface for managing these types, that can also be assigned on a per-category basis, currently available to the Oxfordshire cobrand. (Also include 'TM' in traffic management Exor RDI output.) --- perllib/FixMyStreet/App/Controller/Report.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 27f4393bb..12280db47 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -340,10 +340,16 @@ sub inspect : Private { my %update_params = (); if ($permissions->{report_inspect}) { - foreach (qw/detailed_information traffic_information duplicate_of defect_type/) { + foreach (qw/detailed_information traffic_information duplicate_of/) { $problem->set_extra_metadata( $_ => $c->get_param($_) ); } + if ( $c->get_param('defect_type') ) { + $problem->defect_type($problem->defect_types->find($c->get_param('defect_type'))); + } else { + $problem->defect_type(undef); + } + if ( $c->get_param('include_update') ) { $update_text = Utils::cleanup_text( $c->get_param('public_update'), { allow_multiline => 1 } ); if (!$update_text) { -- cgit v1.2.3 From 112ab20142f7f79d4ffff557b95c53406ad79bd9 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 13 Apr 2017 14:29:56 +0100 Subject: Fix issue with categories with regex characters. As the templates were using `grep`, they failed to match on a category such as "Footpaths (right of way)". Changing the stash variables to be hashes instead of lists makes checking for a key simpler. Fixes #1688. --- perllib/FixMyStreet/App/Controller/Report.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index fe7576893..ad2702460 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -306,7 +306,7 @@ sub inspect : Private { my $problem = $c->stash->{problem}; my $permissions = $c->stash->{_permissions}; - $c->stash->{categories} = $c->forward('/admin/categories_for_point'); + $c->forward('/admin/categories_for_point'); $c->stash->{report_meta} = { map { $_->{name} => $_ } @{ $c->stash->{problem}->get_extra_fields() } }; my %category_body = map { $_->category => $_->body_id } map { $_->contacts->all } values %{$problem->bodies}; -- cgit v1.2.3