Skip to content

Commit

Permalink
check plate type is set
Browse files Browse the repository at this point in the history
  • Loading branch information
sajp committed Aug 8, 2012
1 parent e882672 commit 18013a4
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions lib/LIMS2/WebApp/Controller/User/PlateUpload.pm
Expand Up @@ -54,17 +54,12 @@ sub plate_upload_step2 :Path( '/user/plate_upload_step2' ) :Args(0) {
sub plate_upload_complete :Path( '/user/plate_upload_complete' ) :Args(0) {
my ( $self, $c ) = @_;

unless ( $c->req->param('create_plate') ) {
return $c->res->redirect('/user/plate_upload_step1');
}

$c->stash( $c->request->params );
my $params = $c->request->params;

my $well_data = $c->request->upload('datafile');
unless ( $well_data ) {
$c->stash->{error_msg} = 'No well data';
#TODO this should just be detach?
$c->go( 'plate_upload_step2' );
}

Expand All @@ -73,26 +68,32 @@ sub plate_upload_complete :Path( '/user/plate_upload_complete' ) :Args(0) {
$c->go( 'plate_upload_step2' );
}

unless ( $params->{plate_type} ) {
$c->stash->{error_msg} = 'Must specify a plate type';
$c->go( 'plate_upload_step2' );
}

$params->{species} ||= $c->session->{selected_species};
$params->{created_by} = $c->user->name;

my $plate_data = $c->model('Golgi')->process_plate_data( $params, $well_data->fh );

#my $plate;
#$c->model('Golgi')->txn_do(
#sub {
#try{
#$plate = $c->model('Golgo')->create_plate( $plate_data );
#}
#catch {
#$c->stash->{error_msg} = 'Error encountered while creating plate: ' . $_;
#$c->go( 'plate_upload_step2' );
#};
#$c->model('Golgi')->txn_rollback;
#}
#);

#$c->stash->{plate} = $plate;
my $plate;
$c->model('Golgi')->txn_do(
sub {
try{
$plate = $c->model('Golgi')->create_plate( $plate_data );
}
catch {
$c->stash->{error_msg} = 'Error encountered while creating plate: ' . $_;
$c->go( 'plate_upload_step2' );
$c->model('Golgi')->txn_rollback;
};
}
);
#TODO clear stash

$c->stash->{plate} = $plate;
}

=head1 AUTHOR
Expand Down

0 comments on commit 18013a4

Please sign in to comment.