aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin.pm
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2015-02-02 15:33:42 +0000
committerDave Arter <davea@mysociety.org>2015-10-06 09:09:24 +0100
commit657177eba893c29d6d3f9e4b9f4f24ede5b78bc4 (patch)
treed26ebbf2474beb467c8f9eff591ab71628de6464 /perllib/FixMyStreet/App/Controller/Admin.pm
parent735536dc5e269f2094d122e49f2c648928db4acb (diff)
Add "time spent" admin logging.
Mechanism is general, but current implementation only used for Zurich. - Zurich: Record time_spent field mysociety/FixMyStreet-Commercial#676 - template changes (including jQuery spinner) - backend changes to save data are made: - in log_edit, if supplied - and time on category change (and arbitrary actions) - Add update_admin_log to all paths for DM, ensuring that it gets called, while resetting the `time_spent` parameter, to make sure that there is never a duplicate record created. - Also quell warning about using DateTime values in query. - Also add (seemingly unrelated) parens to stop misparsing of OK line in questionnaire test now that DT::Format::Pg is used in Zurich cobrand See mysociety/FixMyStreet-Commercial#676
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm13
1 files changed, 12 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index be705110b..5ebeffc11 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -1339,13 +1339,24 @@ Adds an entry into the admin_log table using the current user.
=cut
sub log_edit : Private {
- my ( $self, $c, $id, $object_type, $action ) = @_;
+ my ( $self, $c, $id, $object_type, $action, $time_spent ) = @_;
+
+ $time_spent //= 0;
+ $time_spent = 0 if $time_spent < 0;
+
+ my $user_object = do {
+ my $auth_user = $c->user;
+ $auth_user ? $auth_user->get_object : undef;
+ };
+
$c->model('DB::AdminLog')->create(
{
admin_user => $c->forward('get_user'),
+ $user_object ? ( user => $user_object ) : (), # as (rel => undef) doesn't work
object_type => $object_type,
action => $action,
object_id => $id,
+ time_spent => $time_spent,
}
)->insert();
}