| 1 | package Silki::Controller::Process; | ||
| 2 | { | ||
| 3 | $Silki::Controller::Process::VERSION = '0.29'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | use Silki::Schema::Process; | ||
| 11 | |||
| 12 | use Moose; | ||
| 13 | |||
| 14 | BEGIN { extends 'Silki::Controller::Base' } | ||
| 15 | |||
| 16 | sub _set_process : Chained('/') : PathPart('process') : CaptureArgs(1) { | ||
| 17 | my $self = shift; | ||
| 18 | my $c = shift; | ||
| 19 | my $process_id = shift; | ||
| 20 | |||
| 21 | my $process = Silki::Schema::Process->new( process_id => $process_id ); | ||
| 22 | |||
| 23 | if ( $process->wiki_id() ) { | ||
| 24 | my $wiki = Silki::Schema::Wiki->new( wiki_id => $process->wiki_id() ); | ||
| 25 | $self->_require_permission_for_wiki( $c, $wiki, 'Manage' ); | ||
| 26 | } | ||
| 27 | else { | ||
| 28 | $self->_require_site_admin($c); | ||
| 29 | } | ||
| 30 | |||
| 31 | unless ($process) { | ||
| 32 | $c->response()->status(404); | ||
| 33 | $c->detach(); | ||
| 34 | } | ||
| 35 | |||
| 36 | $c->stash()->{process} = $process; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub process : Chained('_set_process') : PathPart('') : Args(0) : ActionClass('+Silki::Action::REST') { | ||
| 40 | } | ||
| 41 | |||
| 42 | sub process_GET { | ||
| 43 | my $self = shift; | ||
| 44 | my $c = shift; | ||
| 45 | |||
| 46 | $self->status_ok( | ||
| 47 | $c, | ||
| 48 | entity => $c->stash()->{process}->serialize(), | ||
| 49 | ); | ||
| 50 | } | ||
| 51 | |||
| 52 | __PACKAGE__->meta()->make_immutable(); | ||
| 53 | |||
| 54 | 1; | ||
| 55 | |||
| 56 | # ABSTRACT: Controller class for processes | ||
| 57 | |||
| 58 | __END__ |