lib/Strehler/Admin.pm

filter: Statementstmt 58.4% 349 / 597 Branchbran 34.5% 76 / 220 Conditioncond 16.3% 30 / 184 MC/DCmcdc 3.3% 3 / 91 Subroutinesub 70.9% 39 / 55 Podpod n/a totaltotal 43.3% 497 / 1147 CC 167 SCAR 37.2
CC
167
Cov
45%
__ANON__
132.0
__ANON__
132.0
__ANON__
123.8
CRAP 41.3
« lib/Strehler/Element.pm ↑ Summary lib/Strehler/Helpers.pm »
1 package Strehler::Admin;
2 12 $Strehler::Admin::VERSION = '1.6.8';
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use Cwd 'abs_path';
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 Dancer2::Plugin::Ajax;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use Dancer2::Serializer::JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use Strehler::Dancer2::Plugin::Admin;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use HTML::FormFu 1.00;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use HTML::FormFu::Element::Block;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use Authen::Passphrase::BlowfishCrypt;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use Time::localtime;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use Strehler::Helpers;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use Strehler::Forms;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use Strehler::Meta::Tag;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use Strehler::Element::Image;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 ▶use Strehler::Element::Article;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 12 ▶use Strehler::Element::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 12 ▶use Strehler::Element::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 12 ▶use Strehler::Meta::Category;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 12 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 12 my @languages;
25  
26 12 ▶if(config->{Strehler}->{languages})
Branch: 1 branch
BranchTrueFalseTotal
if (config()->{'Strehler'}{'languages'}) { } 12 0 12
27 {
28 12 @languages = @{config->{Strehler}->{languages}};
29 }
30 else
31 {
32 0 @languages = ('en');
33 }
34  
35 12 my $module_file_path = __FILE__;
36 12 my $root_path = abs_path($module_file_path);
37 12 $root_path =~ s/Admin\.pm//;
38  
39 12 my $forms_path = $root_path . 'forms';
40  
41 12 set views => $root_path . 'views';
42  
43 ##### Homepage #####
44  
45 1 ▶get '/' => sub {
Subroutine __ANON__: called CC=1 SCAR=1.2
46 1 my $redir = redirect(dancer_app->prefix);
47 0 return $redir;
48 12 };
49 5 ▶get '' => sub {
Subroutine __ANON__: called CC=3 SCAR=12.7
50 5 ▶ if(config->{'Strehler'}->{'dashboard_active'} && config->{'Strehler'}->{'dashboard_active'} == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (config()->{'Strehler'}{'dashboard_active'} and config()->{'Strehler'}{'dashboard_active'} == 1) { } 0 5 5
Condition33%1/3
config()->{"Strehler"}{"dashboard_active"} and config()->{"Strehler"}{"dashboard_active"} == 1
!ll&&!rl&&r
500
MC/DC0%0/2
config()->{"Strehler"}{"dashboard_active"} and config()->{"Strehler"}{"dashboard_active"} == 1
config()->{"Strehler"}{"dashboard_active"} config()->{"Strehler"}{"dashboard_active"} == 1
Truth table33%1/3
A and B
A= config()->{"Strehler"}{"dashboard_active"}B= config()->{"Strehler"}{"dashboard_active"} == 1
ABresult
0X0
100
111
51 {
52 0 redirect dancer_app->prefix . '/dashboard/' . config->{'Strehler'}->{'default_language'};
53 }
54 else
55 {
56 5 my %navbar;
57 5 $navbar{'home'} = "active";
58 5 template "admin/index", { navbar => \%navbar};
59 }
60 12 };
61  
62 ##### Login/Logout #####
63  
64 6 ▶any '/login' => sub {
Subroutine __ANON__: called CC=4 SCAR=14.3
65 6 my $form = Strehler::Forms::form_login();
66 6 my $params_hashref = params;
67 6 $form->process($params_hashref);
68 6 my $message;
69 6 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 6 0 6
70 {
71 6 my $user = Strehler::Element::User->valid_login($params_hashref->{'user'}, $params_hashref->{'password'});
72 6 ▶ if($user)
Branch: 1 branch
BranchTrueFalseTotal
if ($user) { } 5 1 6
73 {
74 5 session 'user' => $user->get_attr('user');
75 5 session 'role' => $user->get_attr('role');
76 5 ▶ if( session 'redir_url' )
Branch: 1 branch
BranchTrueFalseTotal
if (session('redir_url')) { } 0 5 5
77 {
78 0 my $redir = redirect(session 'redir_url');
79 0 return $redir;
80 }
81 else
82 {
83 5 my $redir = redirect(dancer_app->prefix);
84 0 return $redir;
85 }
86 }
87 else
88 {
89 1 $message = "Authentication failed!";
90 }
91 }
92 1 template "admin/login", { form => $form->render(), message => $message }, { layout => 'light-admin' }
93 12 };
94  
95 get '/logout' => sub
96 0 ▶{
Subroutine __ANON__: not called CC=1 SCAR=6.9
97 0 session 'user' => undef;
98 0 session 'role' => undef;
99 0 my $redir = redirect(dancer_app->prefix);
100 0 return $redir;
101 12 };
102  
103 ajax '/image/src/:id' => sub
104 1 ▶{
Subroutine __ANON__: called CC=1 SCAR=0.0
105 1 content_type('text/plain');
106 1 my $id = params->{id};
107 1 my $img = Strehler::Element::Image->new($id);
108 1 return $img->get_attr('image');
109 12 };
110  
111 #Users
112  
113 any '/user/add' => sub
114 3 ▶{
Subroutine __ANON__: called CC=5 SCAR=17.4
115 3 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Element::User->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Element::User"->check_role(session()->read("role")) 0 3 3
Condition20%1/5
'Strehler::Element::User'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
300
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Element::User'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Element::User'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= 'Strehler::Element::User'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
116 3 my $form = Strehler::Forms::form_user('add');
117 3 my $params_hashref = params;
118 3 $form->process($params_hashref);
119 3 my $message = "";
120 3 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 2 1 3
121 {
122 2 my $id = Strehler::Element::User->save_form(undef, $form);
123 2 ▶ if($id >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($id >= 0) { } 2 0 2
124 {
125 2 Strehler::Element::Log->write(session->read('user'), 'add', 'user', $id);
126 2 redirect dancer_app->prefix . '/user/list';
127
128 }
129 else
130 {
131 0 return template "admin/message", { message => Strehler::Element::User->error_message("add", $id), backlink => dancer_app->prefix . '/user' };
132 }
133 }
134 1 template "admin/user", { form => $form->render(), message => $message }
135 12 };
136  
137 0 ▶get '/user/edit/:id' => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
138 0 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Element::User->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Element::User"->check_role(session()->read("role")) 0 0 0
Condition0%0/5
'Strehler::Element::User'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Element::User'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Element::User'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= 'Strehler::Element::User'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
139 0 my $id = params->{id};
140 0 my $user = Strehler::Element::User->new($id);
141 0 my $form_data = $user->get_form_data();
142 0 my $form = Strehler::Forms::form_user('edit');
143 0 $form->default_values($form_data);
144 0 template "admin/user", { form => $form->render() }
145 12 };
146  
147 post '/user/edit/:id' => sub
148 0 ▶{
Subroutine __ANON__: not called CC=5 SCAR=34.0
149 0 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Element::User->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Element::User"->check_role(session()->read("role")) 0 0 0
Condition0%0/5
'Strehler::Element::User'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Element::User'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Element::User'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= 'Strehler::Element::User'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
150 0 my $form = Strehler::Forms::form_user('edit');
151 0 my $id = params->{id};
152 0 my $params_hashref = params;
153 0 $form->process($params_hashref);
154 0 my $message;
155 0 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 0 0 0
156 {
157 0 my $return_id = Strehler::Element::User->save_form($id, $form);
158 0 ▶ if($id >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($id >= 0) { } 0 0 0
159 {
160 0 Strehler::Element::Log->write(session->read('user'), 'edit', 'user', $id);
161 0 redirect dancer_app->prefix . '/user/list';
162 }
163 else
164 {
165 0 return template "admin/message", { message => Strehler::Element::User->error_message("edit", $id), backlink => dancer_app->prefix . '/user' };
166 }
167 }
168 0 template "admin/user", { form => $form->render(), message => $message }
169 12 };
170  
171 1 ▶get '/user/password' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
172 1 my $user = Strehler::Element::User->get_from_username(session->read('user'));
173 1 my $form_data = $user->get_form_data();
174 1 my $form = Strehler::Forms::form_user('password');
175 1 $form->default_values($form_data);
176 1 template "admin/user", { form => $form->render() }
177 12 };
178 post '/user/password' => sub
179 1 ▶{
Subroutine __ANON__: called CC=5 SCAR=18.2
180 1 ▶ send_error("Wrong call", 500) && return if params->{user};
Branch: 1 branch
BranchTrueFalseTotal
if params()->{"user"} 0 1 1
Condition20%1/5
params()->{'user'} && (send_error('Wrong call', 500) && (return))
!ll&&!rl&&r
100
send_error("Wrong call", 500) and return
!ll
00
MC/DC0%0/2
params()->{'user'} && (send_error('Wrong call', 500) && (return))
params()->{'user'} send_error("Wrong call", 500)
Truth table33%1/3
A && B
A= params()->{'user'}B= send_error("Wrong call", 500)
ABresult
0X0
100
111
181 1 my $user = Strehler::Element::User->get_from_username(session->read('user'));
182 1 my $id = $user->get_attr('id');
183 1 my $form = Strehler::Forms::form_user('password');
184 1 my $params_hashref = params;
185 1 $form->process($params_hashref);
186 1 my $message;
187 1 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 1 0 1
188 {
189 1 my $return_id = Strehler::Element::User->save_password($id, $form);
190 1 ▶ if($return_id < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($return_id < 0) { } 0 1 1
191 {
192 0 return template "admin/message", { message => Strehler::Element::User->error_message("change password", $id), backlink => dancer_app->prefix . '/user' };
193 }
194 else
195 {
196 1 Strehler::Element::Log->write(session->read('user'), 'change password', 'user', $id);
197 1 redirect dancer_app->prefix . '/';
198 }
199 }
200 0 template "admin/user", { form => $form->render(), message => $message }
201 12 };
202  
203  
204  
205 #Categories
206  
207 get '/category' => sub
208 0 ▶{
Subroutine __ANON__: not called CC=3 SCAR=24.8
209 0 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 0 0 0
Condition0%0/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
210 0 redirect dancer_app->prefix . '/category/list';
211 12 };
212  
213 any '/category/list' => sub
214 2 ▶{
Subroutine __ANON__: called CC=4 SCAR=15.4
215 2 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 1 1 2
Condition40%2/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
110
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
216  
217 #THE TABLE
218 1 my @to_view = Strehler::Meta::Category->get_list();
219 1 my @entities = Strehler::Helpers::get_categorized_entities();
220  
221 #THE FORM
222 1 my $form = Strehler::Forms::form_category_fast();
223 1 my $params_hashref = params;
224 1 $form->process($params_hashref);
225 1 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 0 1 1
226 {
227 0 my $id = Strehler::Meta::Category->save_form(undef, $form, \@entities);
228 0 Strehler::Element::Log->write(session->read('user'), 'add', 'category', $id);
229 0 redirect dancer_app->prefix . '/category/list?message=fast-created';
230 }
231 1 template "admin/category_list", { categories => \@to_view, form => $form, "message" => params->{'message'}};
232 12 };
233  
234 any '/category/add' => sub
235 15 ▶{
Subroutine __ANON__: called CC=4 SCAR=14.6
236 15 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 0 15 15
Condition20%1/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
1500
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
237 15 my $form = Strehler::Forms::form_category();
238 15 my $params_hashref = params;
239 15 my @entities = Strehler::Helpers::get_categorized_entities();
240 15 $form->process($params_hashref);
241 15 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 14 1 15
242 {
243 14 my $id = Strehler::Meta::Category->save_form(undef, $form, \@entities);
244 14 Strehler::Element::Log->write(session->read('user'), 'add', 'category', $id);
245 14 redirect dancer_app->prefix . '/category/list';
246 }
247 1 template "admin/category", { form => $form->render() }
248 12 };
249 0 ▶get '/category/edit/:id' => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
250 0 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 0 0 0
Condition0%0/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
251 0 my $id = params->{id};
252 0 my $category = Strehler::Meta::Category->new($id);
253 0 my @entities = Strehler::Helpers::get_categorized_entities();
254 0 my $form_data = $category->get_form_data(\@entities);
255 0 $form_data->{'prev-name'} = $form_data->{'category'};
256 0 $form_data->{'prev-parent'} = $form_data->{'parent'};
257 0 my $form = Strehler::Forms::form_category();
258 0 $form->default_values($form_data);
259 0 template "admin/category", { form => $form->render() }
260 12 };
261 post '/category/edit/:id' => sub
262 0 ▶{
Subroutine __ANON__: not called CC=4 SCAR=30.0
263 0 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 0 0 0
Condition0%0/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
264 0 my $form = Strehler::Forms::form_category();
265 0 my $id = params->{id};
266 0 my $params_hashref = params;
267 0 my @entities = Strehler::Helpers::get_categorized_entities();
268 0 $form->process($params_hashref);
269 0 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 0 0 0
270 {
271 0 Strehler::Meta::Category->save_form($id, $form, \@entities);
272 0 Strehler::Element::Log->write(session->read('user'), 'edit', 'category', $id);
273 0 redirect dancer_app->prefix . '/category/list';
274 }
275 0 template "admin/category", { form => $form->render() }
276 12 };
277  
278 get '/category/delete/:id' => sub
279 1 ▶{
Subroutine __ANON__: called CC=3 SCAR=13.0
280 1 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 0 1 1
Condition20%1/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
100
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
281 1 my $id = params->{id};
282 1 my $category = Strehler::Meta::Category->new($id);
283 1 my %data = $category->get_basic_data();
284 1 template "admin/delete-category", { what => "category", subs => $category->is_parent(), el => \%data, backlink => dancer_app->prefix . '/category' };
285 12 };
286 post '/category/delete/:id' => sub
287 2 ▶{
Subroutine __ANON__: called CC=4 SCAR=14.8
288 2 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 0 2 2
Condition20%1/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
200
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
289 2 my $id = params->{id};
290 2 my $category = Strehler::Meta::Category->new($id);
291 2 my $code = $category->delete();
292 2 ▶ if($code != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($code != 0) 1 1 2
293 {
294 1 return template "admin/message", { message => $category->error_message("delete", $code), backlink => dancer_app->prefix . '/category' };
295 }
296 1 Strehler::Element::Log->write(session->read('user'), 'delete', 'category', $id);
297 1 redirect dancer_app->prefix . '/category/list';
298 12 };
299 post '/category/delete-tree/:id' => sub
300 2 ▶{
Subroutine __ANON__: called CC=6 SCAR=18.3
301 2 ▶ send_error("Access denied", 403) && return if ( ! Strehler::Meta::Category->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless "Strehler::Meta::Category"->check_role(session()->read("role")) 0 2 2
Condition20%1/5
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
200
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
'Strehler::Meta::Category'->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
'Strehler::Meta::Category'->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= 'Strehler::Meta::Category'->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
302 2 my $id = params->{id};
303 2 my $category = Strehler::Meta::Category->new($id);
304 2 my @categories_to_delete = ( $category );
305 2 ▶ while(@categories_to_delete)
Branch: 1 branch
BranchTrueFalseTotal
if (@categories_to_delete) 7 1 8
306 {
307 7 my $cat = shift @categories_to_delete;
308 7 ▶ if($cat->is_parent())
Branch: 1 branch
BranchTrueFalseTotal
if ($cat->is_parent) { } 3 4 7
309 {
310 3 @categories_to_delete = ( $cat->subcategories(0), $cat, @categories_to_delete );
311 }
312 else
313 {
314 4 my $code = $cat->delete();
315 4 ▶ if($code != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($code != 0) 1 3 4
316 {
317 1 return template "admin/message", { message => $cat->error_message("delete", $code), backlink => dancer_app->prefix . '/category' };
318 }
319 3 Strehler::Element::Log->write(session->read('user'), 'delete', 'category', $cat->get_attr('id'));
320 }
321 }
322 1 redirect dancer_app->prefix . '/category/list';
323 12 };
324  
325 ajax '/category/select/:id' => sub
326 0 ▶{
Subroutine __ANON__: not called CC=3 SCAR=24.8
327 0 content_type('text/plain');
328 0 my $id = params->{id};
329 0 ▶ my $option = params->{option} || undef;
Condition0%0/2
params()->{'option'} || undef
l!l
00
MC/DC0%0/1
params()->{'option'} || undef
params()->{'option'}
Truth table0%0/2
A
A= params()->{'option'}
Aresult
11
00
330 0 my $data = Strehler::Meta::Category->make_select($id, $option);
331 0 ▶ if($data->[1])
Branch: 1 branch
BranchTrueFalseTotal
if ($data->[1]) { } 0 0 0
332 {
333 0 template 'admin/category_select', { categories => $data }, { layout => undef };
334 }
335 else
336 {
337 0 return 0;
338 }
339 12 };
340 ajax '/category/select' => sub
341 1 ▶{
Subroutine __ANON__: called CC=2 SCAR=7.4
342 1 content_type('text/plain');
343 1 my $data = Strehler::Meta::Category->make_select(undef);
344 1 ▶ if($data->[1])
Branch: 1 branch
BranchTrueFalseTotal
if ($data->[1]) { } 1 0 1
345 {
346 1 template 'admin/category_select', { categories => $data }, { layout => undef };
347 }
348 else
349 {
350 0 return 0;
351 }
352 12 };
353 ajax '/category/info' => sub
354 0 ▶{
Subroutine __ANON__: not called CC=11 SCAR=48.8
355 0 content_type('application/json');
356 0 my $category;
357 0 my $input = params->{input};
358 0 ▶ my $option = params->{option} || undef;
Condition0%0/2
params()->{'option'} || undef
l!l
00
MC/DC0%0/1
params()->{'option'} || undef
params()->{'option'}
Truth table0%0/2
A
A= params()->{'option'}
Aresult
11
00
359 0 my $ancestor = 0;
360 0 ▶ if(params->{query} eq 'id' && $input)
Branch: 2 branches
BranchTrueFalseTotal
if (params()->{'query'} eq 'id' and $input) { } 0 0 0
elsif (params()->{'query'} eq 'name' and $input) { } 0 0 0
Condition0%0/3
params()->{"query"} eq "id" and $input
!ll&&!rl&&r
000
MC/DC0%0/2
params()->{"query"} eq "id" and $input
params()->{"query"} eq "id" $input
Truth table0%0/3
A and B
A= params()->{"query"} eq "id"B= $input
ABresult
0X0
100
111
361 {
362 0 ▶ if($input =~ m/^anc:([0-9]+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($input =~ /^anc:([0-9]+)$/) 0 0 0
363 {
364 0 $input = $1;
365 0 $ancestor = 1;
366 }
367 0 $category = Strehler::Meta::Category->new($input);
368 }
369 ▶ elsif(params->{query} eq 'name' && $input)
Condition0%0/3
params()->{"query"} eq "name" and $input
!ll&&!rl&&r
000
MC/DC0%0/2
params()->{"query"} eq "name" and $input
params()->{"query"} eq "name" $input
Truth table0%0/3
A and B
A= params()->{"query"} eq "name"B= $input
ABresult
0X0
100
111
370 {
371 0 ▶ if($input =~ m/^(.*)\*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($input =~ /^(.*)\*$/) 0 0 0
372 {
373 0 $input = $1;
374 0 $ancestor = 1;
375 }
376 0 $category = Strehler::Meta::Category->explode_name($input);
377 }
378 else
379 {
380 0 $category = Strehler::Meta::Category->new( row => undef );
381 }
382 0 my %data = $category->get_basic_data();
383 0 my $subs = Strehler::Meta::Category->make_select($category->get_attr('id'), $option);
384 0 my @subs_array = @{$subs};
385 0 $data{select} = template 'admin/category_select', { categories => $subs }, { layout => undef };
386 0 ▶ if($#subs_array > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($#subs_array > 0) { } 0 0 0
387 {
388 0 $data{subcategories} = 1;
389 }
390 else
391 {
392 0 $data{subcategories} = 0;
393 }
394 0 ▶ if($ancestor && $category->exists())
Branch: 1 branch
BranchTrueFalseTotal
if ($ancestor and $category->exists) 0 0 0
Condition0%0/3
$ancestor and $category->exists
!ll&&!rl&&r
000
MC/DC0%0/2
$ancestor and $category->exists
$ancestor $category->exists
Truth table0%0/3
A and B
A= $ancestorB= $category->exists
ABresult
0X0
100
111
395 {
396 0 $data{'parent'} = $input;
397 0 $data{subcategories} = 0;
398 0 $data{'ext_name'} = $data{'ext_name'} . "/*";
399 0 $data{'id'} = 'anc:'.$input;
400 }
401 0 my $serializer = Dancer2::Serializer::JSON->new();
402 0 return $serializer->serialize(\%data);
403 12 };
404 ajax '/category/tagform/:type/:id?' => sub
405 0 ▶{
Subroutine __ANON__: not called CC=4 SCAR=30.0
406 0 content_type('text/plain');
407 0 ▶ if(params->{id})
Branch: 1 branch
BranchTrueFalseTotal
if (params()->{'id'}) { } 0 0 0
408 {
409 0 my $category = Strehler::Meta::Category->new(params->{id});
410 0 ▶ if(! $category->exists())
Branch: 1 branch
BranchTrueFalseTotal
if (not $category->exists) { } 0 0 0
411 {
412 0 template 'admin/open_tags';
413 }
414 else
415 {
416 0 my @tags = Strehler::Meta::Tag->get_configured_tags_for_template($category->ext_name(), params->{type});
417 0 ▶ if($#tags > -1)
Branch: 1 branch
BranchTrueFalseTotal
if ($#tags > -1) { } 0 0 0
418 {
419 0 template 'admin/configured_tags', { tags => \@tags }, { layout => undef };
420 }
421 else
422 {
423 0 template 'admin/open_tags';
424 }
425 }
426 }
427 else
428 {
429 0 template 'admin/open_tags';
430 }
431 12 };
432  
433 get '/:entity' => sub
434 0 ▶{
Subroutine __ANON__: not called CC=4 SCAR=30.0
435 0 my $entity = params->{entity};
436 0 my $class = Strehler::Helpers::class_from_entity($entity);
437 0 ▶ if($class)
Branch: 1 branch
BranchTrueFalseTotal
if ($class) { } 0 0 0
438 {
439 0 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 0 0
Condition0%0/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
440 0 redirect dancer_app->prefix . '/' . $entity . '/list';
441 }
442 else
443 {
444 0 return pass;
445 }
446 12 };
447  
448 any '/:entity/list' => sub
449 6 ▶{
Subroutine __ANON__: called CC=15 SCAR=31.9
450 #Page init
451 6 my $entity = params->{entity};
452 6 my $class = Strehler::Helpers::class_from_entity($entity);
453 6 ▶ if(! $class->auto())
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto) 0 6 6
454 {
455 0 return pass;
456 }
457 6 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 6 6
Condition20%1/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
600
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
458  
459 #Parameters collection
460 6 my $input_params;
461 my $session;
462 6 foreach my $p (Strehler::Helpers::list_parameters_names('session'))
463 {
464 36 ▶ if(exists params->{$p})
Branch: 1 branch
BranchTrueFalseTotal
if (exists params()->{$p}) 4 32 36
465 {
466 4 $input_params->{$p} = params->{$p};
467 }
468 36 my $session_value = session->read($entity . "-" . $p);
469 36 ▶ $session->{$p} = $session_value if($session_value);
Branch: 1 branch
BranchTrueFalseTotal
if $session_value 0 36 36
470 }
471 6 foreach my $p (Strehler::Helpers::list_parameters_names('extra'))
472 {
473 24 ▶ if(exists params->{$p})
Branch: 1 branch
BranchTrueFalseTotal
if (exists params()->{$p}) 0 24 24
474 {
475 0 $input_params->{$p} = params->{$p};
476 }
477 }
478 6 my %parameters = Strehler::Helpers::list_parameters_init($entity, $session, $input_params);
479 6 ▶ if(exists $parameters{'error'} && $parameters{'error'} == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parameters{"error"} and $parameters{"error"} == 1) 0 6 6
Condition33%1/3
exists $parameters{"error"} and $parameters{"error"} == 1
!ll&&!rl&&r
600
MC/DC0%0/2
exists $parameters{"error"} and $parameters{"error"} == 1
exists $parameters{"error"} $parameters{"error"} == 1
Truth table33%1/3
A and B
A= exists $parameters{"error"}B= $parameters{"error"} == 1
ABresult
0X0
100
111
480 {
481 0 ▶ my $backlink = params->{'strehl-from'} || "/admin/$entity/list";
Condition0%0/2
params()->{'strehl-from'} || "/admin/$entity/list"
l!l
00
MC/DC0%0/1
params()->{'strehl-from'} || "/admin/$entity/list"
params()->{'strehl-from'}
Truth table0%0/2
A
A= params()->{'strehl-from'}
Aresult
11
00
482 0 return template "admin/message", { message => "Wrong category name: " . params->{'strehl-catname'}, backlink => $backlink };
483 }
484  
485 #Search
486 6 my $elements;
487 6 my %search_params = %parameters;
488 6 ▶ if($parameters{'search'})
Branch: 1 branch
BranchTrueFalseTotal
if ($parameters{'search'}) { } 0 6 6
489 {
490 0 $elements = $class->search_box($parameters{'search'}, \%search_params);
491 }
492 else
493 {
494 6 $elements = $class->get_list(\%search_params);
495 }
496 6 my $filter_form = Strehler::Forms::form_filter($forms_path . '/admin/category_filter.yml', $class->multilang(), $parameters{'language'}, \@languages);
497  
498 #Session saving management
499 6 foreach my $p_save (Strehler::Helpers::list_parameters_names('session'))
500 {
501 36 session $entity . '-' . $p_save => $parameters{$p_save};
502 }
503  
504 #Rendering
505 6 my $custom_list_template = $class->custom_list_template();
506 6 ▶ my $list_view = $custom_list_template ? 'admin/custom_list' : 'admin/generic_list';
Branch: 1 branch
BranchTrueFalseTotal
$custom_list_template ? : 2 4 6
507 template $list_view, { entity => $entity,
508 elements => $elements->{'to_view'},
509 6 last_page => $elements->{'last_page'},
510 filter_form => $filter_form,
511 fields => $class->fields_list(),
512 custom_list_template => $custom_list_template,
513 languages => \@languages,
514 %parameters,
515 $class->entity_data()
516 };
517 12 };
518 get '/:entity/turnon/:id' => sub
519 6 ▶{
Subroutine __ANON__: called CC=7 SCAR=23.5
520 6 my $entity = params->{entity};
521 6 ▶ my $redirect = params->{'strehl-from'} || dancer_app->prefix . '/'. $entity . '/list';
Condition50%1/2
params()->{'strehl-from'} || dancer_app()->prefix . '/' . $entity . '/list'
l!l
06
MC/DC0%0/1
params()->{'strehl-from'} || dancer_app()->prefix . '/' . $entity . '/list'
params()->{'strehl-from'}
Truth table50%1/2
A
A= params()->{'strehl-from'}
Aresult
11
00
522 6 my $class = Strehler::Helpers::class_from_entity($entity);
523 6 ▶ if((! $class->auto()) || (! $class->publishable()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->publishable) 0 6 6
Condition33%1/3
$class->auto and $class->publishable
!ll&&!rl&&r
006
MC/DC0%0/2
$class->auto and $class->publishable
$class->auto $class->publishable
Truth table33%1/3
A and B
A= $class->autoB= $class->publishable
ABresult
0X0
100
111
524 {
525 0 return pass;
526 }
527 6 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 6 6
Condition20%1/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
600
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
528 6 my $id = params->{id};
529 6 my $obj = $class->new($id);
530 6 my $code = $obj->publish();
531 6 ▶ if($code != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($code != 0) 0 6 6
532 {
533 0 return template "admin/message", { message => $obj->error_message("publish", $code), backlink => dancer_app->prefix . '/' . $entity };
534 }
535 6 Strehler::Element::Log->write(session->read('user'), 'publish', $entity, $id);
536 6 redirect $redirect;
537 12 };
538 get '/:entity/turnoff/:id' => sub
539 0 ▶{
Subroutine __ANON__: not called CC=7 SCAR=40.3
540 0 my $entity = params->{entity};
541 0 ▶ my $redirect = params->{'strehl-from'} || dancer_app->prefix . '/'. $entity . '/list';
Condition0%0/2
params()->{'strehl-from'} || dancer_app()->prefix . '/' . $entity . '/list'
l!l
00
MC/DC0%0/1
params()->{'strehl-from'} || dancer_app()->prefix . '/' . $entity . '/list'
params()->{'strehl-from'}
Truth table0%0/2
A
A= params()->{'strehl-from'}
Aresult
11
00
542 0 my $class = Strehler::Helpers::class_from_entity($entity);
543 0 ▶ if((! $class->auto()) || (! $class->publishable()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->publishable) 0 0 0
Condition0%0/3
$class->auto and $class->publishable
!ll&&!rl&&r
000
MC/DC0%0/2
$class->auto and $class->publishable
$class->auto $class->publishable
Truth table0%0/3
A and B
A= $class->autoB= $class->publishable
ABresult
0X0
100
111
544 {
545 0 return pass;
546 }
547 0 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 0 0
Condition0%0/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
548 0 my $id = params->{id};
549 0 my $obj = $class->new($id);
550 0 my $code = $obj->unpublish();
551 0 ▶ if($code != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($code != 0) 0 0 0
552 {
553 0 return template "admin/message", { message => $obj->error_message("unpublish", $code), backlink => dancer_app->prefix . '/' . $entity };
554 }
555 0 Strehler::Element::Log->write(session->read('user'), 'unpublish', $entity, $id);
556 0 redirect $redirect;
557 12 };
558 get '/:entity/delete/:id' => sub
559 0 ▶{
Subroutine __ANON__: not called CC=5 SCAR=34.0
560 0 my $entity = params->{entity};
561 0 my $class = Strehler::Helpers::class_from_entity($entity);
562 0 ▶ if((! $class->auto()) || (! $class->deletable()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->deletable) 0 0 0
Condition0%0/3
$class->auto and $class->deletable
!ll&&!rl&&r
000
MC/DC0%0/2
$class->auto and $class->deletable
$class->auto $class->deletable
Truth table0%0/3
A and B
A= $class->autoB= $class->deletable
ABresult
0X0
100
111
563 {
564 0 return pass;
565 }
566 0 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 0 0
Condition0%0/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
567 0 my $id = params->{id};
568 0 my $obj = $class->new($id);
569 0 my %el = $obj->get_basic_data();
570 0 template "admin/delete", { what => $class->label(), el => \%el, backlink => dancer_app->prefix . '/' . $entity };
571 12 };
572 post '/:entity/delete/:id' => sub
573 3 ▶{
Subroutine __ANON__: called CC=6 SCAR=22.6
574 3 my $entity = params->{entity};
575 3 my $class = Strehler::Helpers::class_from_entity($entity);
576 3 ▶ if((! $class->auto()) || (! $class->deletable()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->deletable) 0 3 3
Condition33%1/3
$class->auto and $class->deletable
!ll&&!rl&&r
003
MC/DC0%0/2
$class->auto and $class->deletable
$class->auto $class->deletable
Truth table33%1/3
A and B
A= $class->autoB= $class->deletable
ABresult
0X0
100
111
577 {
578 0 return pass;
579 }
580 3 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 3 3
Condition20%1/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
300
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
581 3 my $id = params->{id};
582 3 my $obj = $class->new($id);
583 3 my $code = $obj->delete();
584 3 ▶ if($code != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($code != 0) 3 0 3
585 {
586 3 return template "admin/message", { message => $obj->error_message("delete", $code), backlink => dancer_app->prefix . '/' . $entity };
587 }
588 0 Strehler::Element::Log->write(session->read('user'), 'delete', $entity, $id);
589 0 redirect dancer_app->prefix . '/' . $entity . '/list';
590 12 };
591 ajax '/:entity/tagform/:id?' => sub
592 0 ▶{
Subroutine __ANON__: not called CC=7 SCAR=40.3
593 0 content_type('text/plain');
594 0 my $entity = params->{entity};
595 0 my $class = Strehler::Helpers::class_from_entity($entity);
596 0 ▶ if((! $class->auto()) || (! $class->categorized()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->categorized) 0 0 0
Condition0%0/3
$class->auto and $class->categorized
!ll&&!rl&&r
000
MC/DC0%0/2
$class->auto and $class->categorized
$class->auto $class->categorized
Truth table0%0/3
A and B
A= $class->autoB= $class->categorized
ABresult
0X0
100
111
597 {
598 0 return pass;
599 }
600 0 ▶ if(params->{id})
Branch: 1 branch
BranchTrueFalseTotal
if (params()->{'id'}) { } 0 0 0
601 {
602 0 my $obj = $class->new(params->{id});
603 0 my @category_tags = Strehler::Meta::Tag->get_configured_tags_for_template($obj->get_attr('category-name'), $entity);
604 0 my @tags = split(',', $obj->get_tags());
605 0 my @out;
606 0 ▶ if($#category_tags > -1)
Branch: 1 branch
BranchTrueFalseTotal
if ($#category_tags > -1) { } 0 0 0
607 {
608 0 foreach my $c_t (@category_tags)
609 {
610 0 my $default = 0;
611 0 ▶ if (grep {$_ eq $c_t->tag} @tags)
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $c_t->tag;} @tags) 0 0 0
612 {
613 0 $default = 1;
614 }
615 0 push @out, { tag => $c_t->tag, default_tag => $default };
616 }
617 0 template 'admin/configured_tags', { tags => \@out };
618 }
619 else
620 {
621 0 template 'admin/open_tags', { tags => $obj->get_tags() };
622 }
623 }
624 else
625 {
626 0 template 'admin/open_tags';
627 }
628 12 };
629 ajax '/:entity/lastchapter/:id?' => sub
630 0 ▶{
Subroutine __ANON__: not called CC=4 SCAR=30.0
631 0 content_type('text/plain');
632 0 my $entity = params->{entity};
633 0 ▶ my $id = params->{id} || undef;
Condition0%0/2
params()->{'id'} || undef
l!l
00
MC/DC0%0/1
params()->{'id'} || undef
params()->{'id'}
Truth table0%0/2
A
A= params()->{'id'}
Aresult
11
00
634 0 my $class = Strehler::Helpers::class_from_entity($entity);
635 0 ▶ if((! $class->auto()) || (! $class->ordered()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->ordered) 0 0 0
Condition0%0/3
$class->auto and $class->ordered
!ll&&!rl&&r
000
MC/DC0%0/2
$class->auto and $class->ordered
$class->auto $class->ordered
Truth table0%0/3
A and B
A= $class->autoB= $class->ordered
ABresult
0X0
100
111
636 {
637 0 return pass;
638 }
639 0 return $class->max_category_order($id) +1;
640 12 };
641  
642 any '/:entity/add' => sub
643 19 ▶{
Subroutine __ANON__: called CC=24 SCAR=48.2
644 19 my $entity = params->{entity};
645 19 my $class = Strehler::Helpers::class_from_entity($entity);
646 19 ▶ if((! $class->auto()) || (! $class->creatable()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->creatable) 0 19 19
Condition33%1/3
$class->auto and $class->creatable
!ll&&!rl&&r
0019
MC/DC0%0/2
$class->auto and $class->creatable
$class->auto $class->creatable
Truth table33%1/3
A and B
A= $class->autoB= $class->creatable
ABresult
0X0
100
111
647 {
648 0 return pass;
649 }
650  
651 19 my $check_cat = Strehler::Meta::Category->no_categories();
652 19 ▶ if($check_cat and $class->categorized())
Branch: 1 branch
BranchTrueFalseTotal
if ($check_cat and $class->categorized) 2 17 19
Condition66%2/3
$check_cat and $class->categorized
!ll&&!rl&&r
1702
MC/DC50%1/2
$check_cat and $class->categorized
$check_cat $class->categorized
Truth table66%2/3
A and B
A= $check_catB= $class->categorized
ABresult
0X0
100
111
653 {
654 2 my $message = "No category in the system. Create a category before creating categorized content.";
655 2 my $return = dancer_app->prefix . "/";
656 2 my $create = dancer_app->prefix . "/category/add";
657 2 return template "admin/no_category", { message => $message, backlink => $return, createlink => $create };
658 }
659  
660 17 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 17 17
Condition20%1/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
1700
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
661 17 my $form = Strehler::Forms::form_generic($class->form(), $class->multilang_form(), {languages => \@languages, default_language => config->{'Strehler'}->{'default_language'}, only_default_required => $class->only_default_required() } );
662 17 my $params_hashref = params;
663 17 $form = Strehler::Forms::tags_for_form($form, $params_hashref);
664 17 ▶ if(! $form)
Branch: 1 branch
BranchTrueFalseTotal
unless ($form) 0 17 17
665 {
666 0 return pass;
667 }
668 17 $form->process($params_hashref);
669 17 my $message = 'quiet';
670 17 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 15 2 17
671 {
672 15 my $id = $class->save_form(undef, $form, request->uploads());
673 15 ▶ if($id < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($id < 0) 0 15 15
674 {
675 0 return template "admin/message", { message => $class->error_message("delete", $id), backlink => dancer_app->prefix . '/' . $entity };
676 }
677 15 Strehler::Element::Log->write(session->read('user'), 'add', $entity, $id);
678 15 my $action = $form->param_value('strehl-action');
679 15 ▶ if(! $action)
Branch: 1 branch
BranchTrueFalseTotal
unless ($action) 0 15 15
680 {
681 0 ▶ if(session->read('backlink'))
Branch: 1 branch
BranchTrueFalseTotal
if (session()->read('backlink')) { } 0 0 0
682 {
683 0 redirect session->read('backlink');
684 }
685 else
686 {
687 0 redirect dancer_app->prefix . '/' . $entity . '/list';
688 }
689 }
690 15 ▶ if($action eq 'submit-continue')
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq 'submit-continue') { } 0 15 15
691 {
692 0 redirect dancer_app->prefix . '/' . $entity . '/edit/' . $id . '?from_add=1';
693 }
694 else
695 {
696 15 ▶ if(session->read('backlink'))
Branch: 1 branch
BranchTrueFalseTotal
if (session()->read('backlink')) { } 0 15 15
697 {
698 0 redirect session->read('backlink');
699 }
700 else
701 {
702 15 redirect dancer_app->prefix . '/' . $entity . '/list';
703 }
704 }
705 }
706 2 my $fake_tags = $form->get_element({ name => 'tags'});
707 2 ▶ $form->remove_element($fake_tags) if($fake_tags);
Branch: 1 branch
BranchTrueFalseTotal
if $fake_tags 2 0 2
708 2 my $backlink = undef;
709 2 ▶ if(request->method eq 'GET')
Branch: 1 branch
BranchTrueFalseTotal
if (request()->method eq "GET") 0 2 2
710 {
711 0 my $wanted_cat;
712 0 ▶ if(exists params->{'strehl-catname'})
Branch: 1 branch
BranchTrueFalseTotal
if (exists params()->{"strehl-catname"}) 0 0 0
713 {
714 0 $wanted_cat = Strehler::Meta::Category->explode_name(params->{'strehl-catname'});
715 0 ▶ if($wanted_cat->exists())
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted_cat->exists) 0 0 0
716 {
717 0 $form->default_values({ category => $wanted_cat->get_attr('id')});
718 }
719 }
720 0 ▶ if(exists params->{'strehl-today'})
Branch: 1 branch
BranchTrueFalseTotal
if (exists params()->{"strehl-today"}) 0 0 0
721 {
722 0 my $tm = localtime;
723 0 my $tm_day = $tm->mday;
724 0 my $tm_month = $tm->mon + 1;
725 0 my $tm_year = $tm->year + 1900;
726 0 my $date_string = "$tm_day/$tm_month/$tm_year";
727 0 $form->default_values({ publish_date => $date_string });
728 }
729 0 ▶ if(exists params->{'strehl-max-order'})
Branch: 1 branch
BranchTrueFalseTotal
if (exists params()->{"strehl-max-order"}) 0 0 0
730 {
731 0 ▶ if($wanted_cat && $wanted_cat->exists())
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted_cat and $wanted_cat->exists) 0 0 0
Condition0%0/3
$wanted_cat and $wanted_cat->exists
!ll&&!rl&&r
000
MC/DC0%0/2
$wanted_cat and $wanted_cat->exists
$wanted_cat $wanted_cat->exists
Truth table0%0/3
A and B
A= $wanted_catB= $wanted_cat->exists
ABresult
0X0
100
111
732 {
733 0 my $max = $class->max_category_order($wanted_cat->get_attr('id')) + 1;
734 0 $form->default_values({ display_order => $max });
735 }
736 }
737 0 ▶ if(exists params->{'strehl-from'})
Branch: 1 branch
BranchTrueFalseTotal
if (exists params()->{'strehl-from'}) { } 0 0 0
738 {
739 0 $backlink = params->{'strehl-from'};
740 0 session 'backlink' => params->{'strehl-from'};
741 }
742 else
743 {
744 0 session 'backlink' => undef;
745 }
746 }
747 2 ▶ $backlink = $backlink || session->read('backlink');
Condition33%1/3
$backlink || session()->read('backlink')
l!l&&r!l&&!r
002
MC/DC0%0/2
$backlink || session()->read('backlink')
$backlink session()->read('backlink')
Truth table33%1/3
A || B
A= $backlinkB= session()->read('backlink')
ABresult
1X1
011
000
748 2 my %conf_data = $class->entity_data();
749 2 template "admin/generic_add", { entity => $entity, label => $class->label(), form => $form->render(), custom_snippet => $class->custom_add_snippet(), entity_conf => \%conf_data, backlink => $backlink }
750 12 };
751 0 ▶get '/:entity/edit/:id' => sub {
Subroutine __ANON__: not called CC=11 SCAR=48.8
752 0 my $id = params->{id};
753 0 my $entity = params->{entity};
754 0 ▶ my $from_add = params->{from_add} || 0;
Condition0%0/2
params()->{'from_add'} || 0
l!l
00
MC/DC0%0/1
params()->{'from_add'} || 0
params()->{'from_add'}
Truth table0%0/2
A
A= params()->{'from_add'}
Aresult
11
00
755 0 my $class = Strehler::Helpers::class_from_entity($entity);
756 0 my $backlink = undef;
757 0 ▶ if((! $class->auto()) || (! $class->updatable()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->updatable) 0 0 0
Condition0%0/3
$class->auto and $class->updatable
!ll&&!rl&&r
000
MC/DC0%0/2
$class->auto and $class->updatable
$class->auto $class->updatable
Truth table0%0/3
A and B
A= $class->autoB= $class->updatable
ABresult
0X0
100
111
758 {
759 0 return pass;
760 }
761 0 ▶ if(exists params->{'strehl-from'})
Branch: 1 branch
BranchTrueFalseTotal
if (exists params()->{'strehl-from'}) { } 0 0 0
762 {
763 0 $backlink = params->{'strehl-from'};
764 0 session 'backlink' => params->{'strehl-from'};
765 }
766 else
767 {
768 0 ▶ if(! $from_add)
Branch: 1 branch
BranchTrueFalseTotal
unless ($from_add) 0 0 0
769 {
770 0 session 'backlink' => undef;
771 }
772 }
773 0 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 0 0
Condition0%0/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
000
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table0%0/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
774 0 my $el = $class->new($id);
775 0 my $form_data = $el->get_form_data();
776 0 my $form = Strehler::Forms::form_generic($class->form(), $class->multilang_form(), {languages => \@languages, default_language => config->{'Strehler'}->{'default_language'}, only_default_required => $class->only_default_required() } );
777 0 ▶ if(! $form)
Branch: 1 branch
BranchTrueFalseTotal
unless ($form) 0 0 0
778 {
779 0 return pass;
780 }
781 0 $form->default_values($form_data);
782 0 my %conf_data = $class->entity_data();
783 0 ▶ my $message = $from_add ? 'saved' : 'quiet';
Branch: 1 branch
BranchTrueFalseTotal
$from_add ? : 0 0 0
784 0 ▶ $backlink = $backlink || session->read('backlink');
Condition0%0/3
$backlink || session()->read('backlink')
l!l&&r!l&&!r
000
MC/DC0%0/2
$backlink || session()->read('backlink')
$backlink session()->read('backlink')
Truth table0%0/3
A || B
A= $backlinkB= session()->read('backlink')
ABresult
1X1
011
000
785 0 template "admin/generic_add", { entity => $entity, label => $class->label(), id => $id, form => $form->render(), message => $message, custom_snippet => $el->custom_add_snippet(), entity_conf => \%conf_data, backlink => $backlink }
786 12 };
787 post '/:entity/edit/:id' => sub
788 1 ▶{
Subroutine __ANON__: called CC=13 SCAR=40.0
789 1 my $id = params->{id};
790 1 my $entity = params->{entity};
791 1 my $class = Strehler::Helpers::class_from_entity($entity);
792 1 ▶ if((! $class->auto()) || (! $class->updatable()))
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->auto and $class->updatable) 0 1 1
Condition33%1/3
$class->auto and $class->updatable
!ll&&!rl&&r
001
MC/DC0%0/2
$class->auto and $class->updatable
$class->auto $class->updatable
Truth table33%1/3
A and B
A= $class->autoB= $class->updatable
ABresult
0X0
100
111
793 {
794 0 return pass;
795 }
796 1 ▶ send_error("Access denied", 403) && return if ( ! $class->check_role(session->read('role')));
Branch: 1 branch
BranchTrueFalseTotal
unless $class->check_role(session()->read("role")) 0 1 1
Condition20%1/5
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
l!l&&r!l&&!r
100
send_error("Access denied", 403) and return
!ll
00
MC/DC0%0/2
$class->check_role(session()->read('role')) || send_error('Access denied', 403) && (return)
$class->check_role(session()->read('role')) send_error("Access denied", 403)
Truth table33%1/3
A || B
A= $class->check_role(session()->read('role'))B= send_error("Access denied", 403)
ABresult
1X1
011
000
797 1 my $form = Strehler::Forms::form_generic($class->form(), $class->multilang_form(), {languages => \@languages, default_language => config->{'Strehler'}->{'default_language'}, only_default_required => $class->only_default_required() } );
798 1 ▶ if(! $form)
Branch: 1 branch
BranchTrueFalseTotal
unless ($form) 0 1 1
799 {
800 0 return pass;
801 }
802 1 my $params_hashref = params;
803 1 $form = Strehler::Forms::tags_for_form($form, $params_hashref);
804 1 $form->process($params_hashref);
805 1 my $message = 'quiet';
806 1 ▶ if($form->submitted_and_valid)
Branch: 1 branch
BranchTrueFalseTotal
if ($form->submitted_and_valid) 0 1 1
807 {
808 0 my $id = $class->save_form($id, $form, request->uploads()); ## no critic qw(Variables::ProhibitReusedNames)
809 0 ▶ if($id < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($id < 0) 0 0 0
810 {
811 0 return template "admin/message", { message => $class->error_message("edit", $id), backlink => dancer_app->prefix . '/' . $entity };
812 }
813  
814 0 Strehler::Element::Log->write(session->read('user'), 'edit', $entity, $id);
815 0 my $action = $form->param_value('strehl-action');
816 0 ▶ if(! $action)
Branch: 3 branches
BranchTrueFalseTotal
if (not $action) { } 0 0 0
elsif ($action eq 'submit-go') { } 0 0 0
elsif ($action eq 'submit-continue') { } 0 0 0
817 {
818 0 ▶ if(session->read('backlink'))
Branch: 1 branch
BranchTrueFalseTotal
if (session()->read('backlink')) { } 0 0 0
819 {
820 0 redirect session->read('backlink');
821 }
822 else
823 {
824 0 redirect dancer_app->prefix . '/' . $entity . '/list';
825 }
826 }
827 elsif($action eq 'submit-go')
828 {
829 0 ▶ if(session->read('backlink'))
Branch: 1 branch
BranchTrueFalseTotal
if (session()->read('backlink')) { } 0 0 0
830 {
831 0 redirect session->read('backlink');
832 }
833 else
834 {
835 0 redirect dancer_app->prefix . '/' . $entity . '/list';
836 }
837 }
838 elsif($action eq 'submit-continue')
839 {
840 0 $message = 'saved';
841 }
842 }
843 1 my $el = $class->new($id);
844 1 my %conf_data = $class->entity_data();
845 1 my $backlink = session->read('backlink');
846 1 template "admin/generic_add", { entity => $entity, label => $class->label(), id => $id, form => $form->render(), message => $message, custom_snippet => $el->custom_add_snippet(), entity_conf => \%conf_data, backlink => $backlink }
847 12 };
848  
849 ##### DASHBOARD #####
850  
851 3 ▶get '/dashboard/:lang' => sub {
Subroutine __ANON__: called CC=16 SCAR=28.4
852 3 ▶ if(! config->{'Strehler'}->{'dashboard_active'} || config->{'Strehler'}->{'dashboard_active'} == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (not config()->{"Strehler"}{"dashboard_active"} or config()->{"Strehler"}{"dashboard_active"} == 0) 0 3 3
Condition33%1/3
not config()->{"Strehler"}{"dashboard_active"} or config()->{"Strehler"}{"dashboard_active"} == 0
l!l&&r!l&&!r
003
MC/DC0%0/2
not config()->{"Strehler"}{"dashboard_active"} or config()->{"Strehler"}{"dashboard_active"} == 0
not config()->{"Strehler"}{"dashboard_active"} config()->{"Strehler"}{"dashboard_active"} == 0
Truth table33%1/3
not(A) or B
A= not config()->{"Strehler"}{"dashboard_active"}B= config()->{"Strehler"}{"dashboard_active"} == 0
ABresult
1X1
011
000
853 {
854 0 return pass;
855 }
856 3 my %navbar;
857 3 $navbar{'home'} = "active";
858 3 my $language = params->{'lang'};
859 3 ▶ if ( ! grep { $_ eq $language } @languages )
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $language;} @languages) 1 2 3
860 {
861 1 return pass;
862 }
863  
864 2 my $dashboard_data = config->{'Strehler'}->{'dashboard'};
865 2 my $elid = 0;
866 2 foreach my $el (@{$dashboard_data})
867 {
868 4 $el->{id} = $elid++;
869 4 ▶ $el->{entity} ||= 'article';
Condition100%2/2
$el->{"entity"} ||= "article"
l!l
31
MC/DC100%1/1
$el->{"entity"} ||= "article"
$el->{"entity"}
Truth table100%2/2
A
A= $el->{"entity"}
Aresult
11
00
870 4 ▶ if($el->{'type'} eq 'list')
Branch: 2 branches
BranchTrueFalseTotal
if ($el->{'type'} eq 'list') { } 2 2 4
elsif ($el->{'type'} eq 'page') { } 2 0 2
871 {
872 2 my $cat = Strehler::Meta::Category->explode_name($el->{'category'});
873 2 ▶ if($cat->exists())
Branch: 1 branch
BranchTrueFalseTotal
if ($cat->exists) { } 2 0 2
874 {
875 2 $el->{'nocategory'} = 0;
876 2 my $class = Strehler::Helpers::class_from_entity($el->{'entity'});
877 my $elements = $class->get_list({ entries_per_page => -1,
878 2 category => $el->{'category'},
879 language => $language,
880 published => 1
881 });
882 2 my @list = @{$elements->{'to_view'}};
883 2 $el->{'counter'} = $#list+1;
884 my $unpub_elements = $class->get_list({ entries_per_page => -1,
885 2 category => $el->{'category'},
886 language => $language,
887 published => 0
888 });
889 2 my @unpub_list = @{$unpub_elements->{'to_view'}};
890 2 $el->{'unpublished_counter'} = $#unpub_list+1;
891 2 ▶ my $by = $el->{'by'} || 'date';
Condition50%1/2
$el->{'by'} || 'date'
l!l
20
MC/DC0%0/1
$el->{'by'} || 'date'
$el->{'by'}
Truth table50%1/2
A
A= $el->{'by'}
Aresult
11
00
892 2 $el->{'by'} = $by;
893 }
894 else
895 {
896 0 $el->{'counter'} = 0;
897 0 $el->{'unpublished_counter'} = 0;
898 0 $el->{'nocategory'} = 1;
899 }
900 }
901 elsif($el->{'type'} eq 'page')
902 {
903 2 my $total_elements = 0;
904 2 my $published_elements = 0;
905 2 foreach my $piece (@{$el->{'elements'}})
906 {
907 4 my $cat = Strehler::Meta::Category->explode_name($piece->{'category'});
908 4 ▶ $piece->{'entity'} ||= 'article';
Condition50%1/2
$piece->{"entity"} ||= "article"
l!l
40
MC/DC0%0/1
$piece->{"entity"} ||= "article"
$piece->{"entity"}
Truth table50%1/2
A
A= $piece->{"entity"}
Aresult
11
00
909 4 ▶ if($cat->exists())
Branch: 1 branch
BranchTrueFalseTotal
if ($cat->exists) { } 4 0 4
910 {
911 4 $el->{'nocategory'} = 0;
912 4 $total_elements++;
913 4 my $class = Strehler::Helpers::class_from_entity($piece->{'entity'});
914 4 ▶ my $by = $piece->{'by'} || 'date';
Condition100%2/2
$piece->{'by'} || 'date'
l!l
31
MC/DC100%1/1
$piece->{'by'} || 'date'
$piece->{'by'}
Truth table100%2/2
A
A= $piece->{'by'}
Aresult
11
00
915 4 $piece->{'by'} = $by;
916 4 my ($latest_published, $latest_unpublished) = $class->get_last_pubunpub($piece->{'category'}, $language, $by);
917 4 ▶ if($latest_unpublished)
Branch: 1 branch
BranchTrueFalseTotal
if ($latest_unpublished) { } 2 2 4
918 {
919 2 my %latest_unpub_data = $latest_unpublished->get_ext_data($language);
920 2 $piece->{'latest_unpublished'} = \%latest_unpub_data;
921 }
922 else
923 {
924 2 $piece->{'latest_unpublished'} = undef;
925 }
926 4 ▶ if($latest_published)
Branch: 1 branch
BranchTrueFalseTotal
if ($latest_published) { } 2 2 4
927 {
928 2 $published_elements++;
929 2 my %latest_pub_data = $latest_published->get_ext_data($language);
930 2 $piece->{'latest_published'} = \%latest_pub_data;
931 }
932 else
933 {
934 2 $piece->{'latest_published'} = undef;
935 }
936 }
937 else
938 {
939 0 $total_elements++;
940 0 $piece->{'nocategory'} = 1;
941 }
942 }
943 2 $el->{'published_elements'} = $published_elements;
944 2 $el->{'total_elements'} = $total_elements;
945 }
946 }
947 2 template "admin/dashboard", { language => $language, languages => \@languages, navbar => \%navbar, dashboard => config->{'Strehler'}->{'dashboard'}};
948 12 };
949  
950 ### MESSAGES ###
951  
952 0 ▶get '/sys/warnings' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
953 0 my @messages = ();
954 0 ▶ if(! Strehler::Helpers::check_statics())
Branch: 1 branch
BranchTrueFalseTotal
unless (Strehler::Helpers::check_statics()) 0 0 0
955 {
956 0 push @messages, "Strehler statics are not aligned with installed release. Run <strong>strehler statics</strong> to solve."
957 }
958 0 template "admin/warnings", { messages => \@messages, no_war => 1 };
959 12 };
960  
961 =encoding utf8
962  
963 =head1 NAME
964  
965 Strehler::Admin - App holding the routes used by Strehler backend
966  
967 =head1 DESCRIPTION
968  
969 Strehler::Admin holds all the routes used by Strehler to erogate views. It also contains some helpers, mostly about form management, called inside routes.
970  
971 The use of the L<Strehler::Dancer2::Plugin::Admin> makes all the routes to have /admin as prefix.
972  
973 Routes have the structure:
974  
975 /entity/action/id
976  
977 Where B<entity> represent a L<Strehler::Element> class, action is usually a standard action of a CRUD interface and id (where needed) is the identifier of the object cosidered.
978  
979 =head1 SYNOPSIS
980  
981 Strehler::Admin is just a Dancer2 app so you need to add it to your bin/app.pl script to use it.
982  
983 #!/usr/bin/env perl
984  
985 use FindBin;
986 use lib "$FindBin::Bin/../lib";
987  
988 use Site;
989 use Strehler::Admin;
990  
991 Site->dance;
992  
993 Never add the C<use Strehler::Admin> line as the first App included to not mess with site directories (public, lib...)
994  
995 =cut
996  
997  
998 12 1;
« lib/Strehler/Element.pm ↑ Summary lib/Strehler/Helpers.pm »