Skip to content
Browse files

Make sure all types are assigned to an interface

  • Loading branch information...
1 parent 99c3720 commit b973eb67d9a80e344ec17eecc123b0c24fd70041 @cgx cgx committed May 24, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 html/configurator/lib/configurator/Controller/Wizard.pm
View
20 html/configurator/lib/configurator/Controller/Wizard.pm
@@ -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 {

0 comments on commit b973eb6

Please sign in to comment.
Something went wrong with that request. Please try again.