File Coverage

blib/lib/meon/Web/Form/ExtendMembership.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package meon::Web::Form::ExtendMembership;
2              
3 2     2   13042019 use meon::Web::Util;
  0            
  0            
4             use Class::Load 'load_class';
5              
6             use HTML::FormHandler::Moose;
7             extends 'HTML::FormHandler';
8             with 'meon::Web::Role::Form';
9              
10             has '+name' => (default => 'form-member-update');
11             has '+widget_wrapper' => ( default => 'Bootstrap' );
12             sub build_form_element_class { ['form-horizontal'] };
13              
14             sub submitted {
15             my $self = shift;
16              
17             my $c = $self->c;
18             my $post_process = eval { $self->get_config_text('post-process') };
19             my $profiles_dir = meon::Web::env->profiles_dir;
20             my $username = $c->req->body_params->{username};
21             my $member = meon::Web::Member->new(
22             members_folder => $profiles_dir,
23             username => $username,
24             );
25             my $member_pre_status = $member->user->status;
26              
27             $c->detach('/status_not_found', ['failed to load user'])
28             unless eval { $member->xml };
29              
30             $member->extend_expiration_by_1y;
31              
32             if ($post_process) {
33             load_class($post_process);
34              
35             if ($member_pre_status eq 'registration-pending') {
36             $post_process->member_registred($member);
37             }
38             else {
39             $post_process->membership_extended($member);
40             }
41             }
42              
43             $self->redirect('');
44             }
45              
46             no HTML::FormHandler::Moose;
47              
48             1;