1 package SL::Controller::ProjectStatus;
5 use parent qw(SL::Controller::Base);
7 use SL::DB::ProjectStatus;
10 use Rose::Object::MakeMethods::Generic
12 scalar => [ qw(project_status) ],
15 __PACKAGE__->run_before('check_auth');
16 __PACKAGE__->run_before('load_project_status', only => [ qw(edit update destroy) ]);
25 $self->render('project_status/list',
26 title => $::locale->text('Project Status'),
27 PROJECT_STATUS => SL::DB::Manager::ProjectStatus->get_all_sorted);
33 $self->{project_status} = SL::DB::ProjectStatus->new;
34 $self->render('project_status/form', title => $::locale->text('Create a new project status'));
39 $self->render('project_status/form', title => $::locale->text('Edit project status'));
45 $self->{project_status} = SL::DB::ProjectStatus->new;
46 $self->create_or_update;
51 $self->create_or_update;
57 if (eval { $self->{project_status}->delete; 1; }) {
58 flash_later('info', $::locale->text('The project status has been deleted.'));
60 flash_later('error', $::locale->text('The project status is in use and cannot be deleted.'));
63 $self->redirect_to(action => 'list');
69 SL::DB::ProjectStatus->reorder_list(@{ $::form->{project_status_id} || [] });
71 $self->render(\'', { type => 'json' });
79 $::auth->assert('config');
86 sub create_or_update {
88 my $is_new = !$self->{project_status}->id;
89 my $params = delete($::form->{project_status}) || { };
91 $self->{project_status}->assign_attributes(%{ $params });
93 my @errors = $self->{project_status}->validate;
96 flash('error', @errors);
97 $self->render('project_status/form', title => $is_new ? $::locale->text('Create a new project status') : $::locale->text('Edit project status'));
101 $self->{project_status}->save;
103 flash_later('info', $is_new ? $::locale->text('The project status has been created.') : $::locale->text('The project status has been saved.'));
104 $self->redirect_to(action => 'list');
107 sub load_project_status {
109 $self->{project_status} = SL::DB::ProjectStatus->new(id => $::form->{id})->load;