lib/Rapi/Blog/Module/PostPage.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 69 CC 3 SCAR 16.7
CC
3
Cov
0%
apply_permissions
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.3
1 package Rapi::Blog::Module::PostPage;
2  
3 use strict;
4 use warnings;
5  
6 use Moose;
7 extends 'RapidApp::Module::DbicRowDV';
8  
9 use RapidApp::Util qw(:all);
10 use Rapi::Blog::Util;
11 use Path::Class qw(file dir);
12  
13 has '+template', default => 'templates/dv/postview.html';
14  
15 has '+tt_include_path', default => sub {
16 my $self = shift;
17 dir( $self->app->ra_builder->share_dir )->stringify;
18 };
19  
20 has '+destroyable_relspec', default => sub {['*']};
21 has '+close_on_destroy' , default => 1;
22 has '+confirm_on_destroy', default => 0;
23  
24 before 'content' => sub { (shift)->apply_permissions };
25  
26 sub apply_permissions {
27 my $self = shift;
28 my $c = RapidApp->active_request_context or return;
29
30 # System 'administrator' role trumps everything:
31 return if ($c->check_user_roles('administrator'));
32  
33 my $Post = $self->req_Row or return;
34
35 my @excl = ('create');
36
37 if($Post->can_modify) {
38 $Post->can_change_author or $self->apply_columns({ author => { allow_edit => 0 } });
39 }
40 else {
41 push @excl, 'update';
42 }
43
44 $Post->can_delete or push @excl, 'destroy';
45
46 $self->apply_extconfig( store_exclude_api => \@excl );
47 }
48  
49  
50 1;
51