aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-12-01 18:25:24 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-12-16 10:21:55 +0000
commit2abd85a6d9151f95c82656df9e6b8220e381ca03 (patch)
tree5fa4145bdad659cdc70e86f3604f6c37544f8249 /perllib/FixMyStreet/App
parent34f942d7881451e164431a3231774568421a00f5 (diff)
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.
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Root.pm1
2 files changed, 7 insertions, 2 deletions
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',
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index 1df249999..20a871b17 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -108,6 +108,7 @@ sub page_error_403_access_denied : Private {
sub page_error_400_bad_request : Private {
my ( $self, $c, $error_msg ) = @_;
+ $c->forward('/auth/get_csrf_token');
$c->detach('page_error', [ $error_msg, 400 ]);
}