source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Templates.pm @ 2361

Last change on this file since 2361 was 2361, checked in by nanardon, 4 years ago

Add templates management pages

File size: 1.5 KB
Line 
1package LATMOS::Accounts::Web::Controller::Templates;
2use Moose;
3use namespace::autoclean;
4
5BEGIN { extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9LATMOS::Accounts::Web::Controller::Templates - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index :Path :Args(0) {
25    my ( $self, $c ) = @_;
26
27    $c->stash->{ofilter} = $c->model('AttrFilter', 'templates');
28}
29
30sub default :LocalPath {
31    my ( $self, $c, undef, $template) = @_;
32
33    my $db = $c->model('Accounts')->db;
34
35    my $otemplate = $db->get_object('templates', $template);
36    $c->stash->{templatesname} = $template;
37    $c->stash->{templates} = $otemplate;
38    $c->stash->{page}{title} = "Gestion des templates";
39
40    $c->stash->{form} = $c->model('AttrForms', 'templates', $otemplate);
41
42    if ($c->req->param('make_active')) {
43        $c->stash->{templates}->set_c_fields('exported' => 1);
44        $db->commit;
45    }
46    elsif ($c->req->param('make_inactive')) {
47        $c->stash->{templates}->set_c_fields('exported' => 0);
48        $db->commit;
49    }
50    elsif ($c->req->param('delete')) {
51        $db->delete_object('templates', $template);
52        $db->commit;
53        $c->res->redirect('/templates');
54        return;
55    }
56    else {
57        $c->stash->{form}->set_attrs;
58    }
59}
60
61
62
63=encoding utf8
64
65=head1 AUTHOR
66
67Olivier Thauvin,Guyancourt-B1428,+33 1 80285052,
68
69=head1 LICENSE
70
71This library is free software. You can redistribute it and/or modify
72it under the same terms as Perl itself.
73
74=cut
75
76__PACKAGE__->meta->make_immutable;
77
781;
Note: See TracBrowser for help on using the repository browser.