Skip to content

Commit

Permalink
Updated audit to use local timezone (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts-ctrlo authored Jun 20, 2024
1 parent a9d8b67 commit 73dc96f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
12 changes: 12 additions & 0 deletions lib/GADS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4794,4 +4794,16 @@ sub _process_edit

}

Sub::Install::install_sub({
code => sub {
my $self= shift;
my $clone = $self->clone;
$clone->time_zone->is_floating && $clone->set_time_zone('UTC');
$clone->set_time_zone('Europe/London');
$clone->strftime('%e %b %Y %H:%M:%S');
},
into => 'DateTime',
as => 'gads_time',
});

true;
21 changes: 13 additions & 8 deletions lib/GADS/Audit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,21 @@ sub logs
-desc => 'datetime',
},
});
$rs->result_class('DBIx::Class::ResultClass::HashRefInflator');

my @logs = $rs->all;
my $site = $self->schema->resultset('Site')->next;
$_->{user} = GADS::Datum::Person->new(
schema => $self->schema,
init_value => $_->{user},
)->presentation(type => 'person', site => $site) foreach @logs;
\@logs;

my @result = map {
+{
id => $_->id,
type => $_->type,
datetime => $_->datetime->gads_time,
description => $_->description,
user => $_->user,
}
} @logs;

\@result;
}

sub csv
Expand All @@ -191,5 +198,3 @@ sub csv
}

1;


2 changes: 1 addition & 1 deletion views/admin/audit.tt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
label = log.id
},{
type = "text"
label = log.user.text
label = log.user.value
filter = "html"
},{
type = "text"
Expand Down

0 comments on commit 73dc96f

Please sign in to comment.