lib/Strehler/Element/Log.pm

filter: Statementstmt 62.2% 33 / 53 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 38.8% 7 / 18 Podpod 15.3% 2 / 13 totaltotal 50.0% 42 / 84 CC 1 SCAR 4.8
CC
1
Cov
62%
exposed
2.0
label
2.0
creatable
2.0
CRAP 1.6
« lib/Strehler/Element/Role/Slugged.pm ↑ Summary lib/Strehler/Element/Article.pm »
1 package Strehler::Element::Log;
2 12 $Strehler::Element::Log::VERSION = '1.6.8';
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Dancer2 0.166001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Dancer2::Plugin::DBIC;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use DateTime::Format::Strptime;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 extends 'Strehler::Element';
10  
11 #Standard element implementation
12  
13 12 my $root_path = __FILE__;
14 12 $root_path =~ s/Log\.pm//;
15 12 my $form_path = $root_path . "../forms";
16 12 my $views_path = $root_path . "../views";
17  
18 sub metaclass_data
19 81 ▶{
Subroutine metaclass_data: called CC=1 SCAR=0.0
Pod undocumented
20 81 my $self = shift;
21 81 my $param = shift;
22 81 my %element_conf = ( item_type => 'log',
23 ORMObj => 'ActivityLog',
24 category_accessor => '',
25 multilang_children => '' );
26 81 return $element_conf{$param};
27 }
28  
29 #Standard configuration overrides
30 sub exposed
31 0 ▶{
Subroutine exposed: not called CC=1 SCAR=6.9
Pod undocumented
32 0 my $self = shift;
33 0 return $self->_property('exposed', 0);
34 }
35 sub label
36 0 ▶{
Subroutine label: not called CC=1 SCAR=6.9
Pod undocumented
37 0 my $self = shift;
38 0 return $self->_property('label', 'Logs');
39 }
40 sub creatable
41 0 ▶{
Subroutine creatable: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my $self = shift;
43 0 return $self->_property('creatable', 0);
44 }
45 sub updatable
46 0 ▶{
Subroutine updatable: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my $self = shift;
48 0 return $self->_property('updatable', 0);
49 }
50 sub deletable
51 0 ▶{
Subroutine deletable: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my $self = shift;
53 0 return $self->_property('deletable', 0);
54 }
55 sub allowed_role
56 0 ▶{
Subroutine allowed_role: not called CC=1 SCAR=6.9
Pod undocumented
57 0 my $self = shift;
58 0 return $self->_property('allowed_role', 'admin');
59 }
60 sub class
61 0 ▶{
Subroutine class: not called CC=1 SCAR=6.9
Pod undocumented
62 0 return __PACKAGE__;
63 }
64  
65 sub write
66 42 ▶{
Subroutine write: called CC=1 SCAR=0.0
Pod undocumented
67 42 my $self = shift;
68 42 my $user = shift;
69 42 my $action = shift;
70 42 my $entity_type = shift;
71 42 my $entity_id = shift;
72 42 my $log_row = $self->get_schema()->resultset($self->ORMObj())->create({ user => $user, action => $action, entity_type => $entity_type, entity_id => $entity_id, timestamp => DateTime->now() });
73  
74 42 return $log_row;
75 }
76  
77 sub main_title
78 0 ▶{
Subroutine main_title: not called CC=1 SCAR=6.9
Pod documented
79 0 my $self = shift;
80 0 return "[" . $self->get_attr('timestamp') . "] " . $self->get_attr('action') . " " . $self->get_attr('entity_type');
81 }
82  
83 sub fields_list
84 0 ▶{
Subroutine fields_list: not called CC=1 SCAR=6.9
Pod documented
85 0 my $self = shift;
86 0 my @fields = ( { 'id' => 'id',
87 'label' => 'ID',
88 'ordinable' => 1 },
89 { 'id' => 'timestamp',
90 'label' => 'Timestamp',
91 'ordinable' => 1 },
92 { 'id' => 'user',
93 'label' => 'User',
94 'ordinable' => 1 },
95 { 'id' => 'action',
96 'label' => 'Action',
97 'ordinable' => 0 },
98 { 'id' => 'object',
99 'label' => 'Object',
100 'ordinable' => 0 }
101 );
102 0 return \@fields;
103
104 }
105 sub custom_list_template
106 0 ▶{
Subroutine custom_list_template: not called CC=1 SCAR=6.9
Pod undocumented
107 0 return $views_path . "/admin/entities/log_list_block.tt";
108 }
109  
110 sub install
111 0 ▶{
Subroutine install: not called CC=1 SCAR=6.9
Pod undocumented
112 0 return "Standard entity. No installation is needed.";
113 }
114  
115  
116  
117 =encoding utf8
118  
119 =head1 NAME
120  
121 Strehler::Element::Log - Strehler Entity for logs
122  
123 =head1 DESCRIPTION
124  
125 A little entity used to log Strehler backend actions and keep trace of it.
126  
127 =cut
128  
129 12 1;
130  
« lib/Strehler/Element/Role/Slugged.pm ↑ Summary lib/Strehler/Element/Article.pm »