1 package SL::Controller::RequirementSpecAcceptanceStatus;
5 use parent qw(SL::Controller::Base);
7 use SL::DB::RequirementSpecAcceptanceStatus;
10 use SL::Locale::String;
12 use Rose::Object::MakeMethods::Generic
14 scalar => [ qw(requirement_spec_acceptance_status valid_names) ],
17 __PACKAGE__->run_before('check_auth');
18 __PACKAGE__->run_before('load_requirement_spec_acceptance_status', only => [ qw(edit update destroy) ]);
19 __PACKAGE__->run_before(sub { $_[0]->valid_names(\@SL::DB::RequirementSpecAcceptanceStatus::valid_names) });
28 $self->render('requirement_spec_acceptance_status/list',
29 title => t8('Acceptance Statuses'),
30 REQUIREMENT_SPEC_ACCEPTANCE_STATUSES => SL::DB::Manager::RequirementSpecAcceptanceStatus->get_all_sorted);
36 $self->{requirement_spec_acceptance_status} = SL::DB::RequirementSpecAcceptanceStatus->new;
37 $self->render('requirement_spec_acceptance_status/form', title => t8('Create a new acceptance status'));
42 $self->render('requirement_spec_acceptance_status/form', title => t8('Edit acceptance status'));
48 $self->{requirement_spec_acceptance_status} = SL::DB::RequirementSpecAcceptanceStatus->new;
49 $self->create_or_update;
54 $self->create_or_update;
60 if (eval { $self->{requirement_spec_acceptance_status}->delete; 1; }) {
61 flash_later('info', t8('The acceptance status has been deleted.'));
63 flash_later('error', t8('The acceptance status is in use and cannot be deleted.'));
66 $self->redirect_to(action => 'list');
72 SL::DB::RequirementSpecAcceptanceStatus->reorder_list(@{ $::form->{requirement_spec_acceptance_status_id} || [] });
74 $self->render(\'', { type => 'json' });
82 $::auth->assert('config');
89 sub create_or_update {
91 my $is_new = !$self->{requirement_spec_acceptance_status}->id;
92 my $params = delete($::form->{requirement_spec_acceptance_status}) || { };
93 my $title = $is_new ? t8('Create a new acceptance status') : t8('Edit acceptance status');
95 $self->{requirement_spec_acceptance_status}->assign_attributes(%{ $params });
97 my @errors = $self->{requirement_spec_acceptance_status}->validate;
100 flash('error', @errors);
101 $self->render('requirement_spec_acceptance_status/form', title => $title);
105 $self->{requirement_spec_acceptance_status}->save;
107 flash_later('info', $is_new ? t8('The acceptance status has been created.') : t8('The acceptance status has been saved.'));
108 $self->redirect_to(action => 'list');
111 sub load_requirement_spec_acceptance_status {
113 $self->{requirement_spec_acceptance_status} = SL::DB::RequirementSpecAcceptanceStatus->new(id => $::form->{id})->load;