Skip to content

Commit

Permalink
Make sure all types are assigned to an interface
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed May 24, 2012
1 parent 99c3720 commit b973eb6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions html/configurator/lib/configurator/Controller/Wizard.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ sub step1 :Chained('object') :PathPart('step1') :Args(0) {
types => $data->{types},
enforcements => {});
map { $c->session->{enforcements}->{$_} = 1 } @{$data->{enforcements}};

# Make sure all types for each enforcement is assigned to an interface
# TODO: Shall we ignore disabled interfaces
my @selected_types = values %{$data->{types}};
my %seen;
my @missing = ();
@seen{@selected_types} = ( ); # build lookup table

foreach my $enforcement (@{$data->{enforcements}}) {
my $types = $c->model('Enforcement')->getAvailableTypes($enforcement);
foreach my $type (@{$types}) {
push(@missing, $type) unless exists $seen{$type};
}
}

if (scalar @missing > 0) {
$c->response->status($STATUS::PRECONDITION_FAILED);
$c->stash->{status_msg} = $c->loc("You must assign an interface to the following types: [_1]", join(", ", @missing));
}

$c->stash->{current_view} = 'JSON';
}
else {
Expand Down

0 comments on commit b973eb6

Please sign in to comment.