Fix trial creation
This commit is contained in:
@@ -206,6 +206,34 @@ $config['parameters/create'] = array(
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for creating projects.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['projects/create'] = array(
|
||||
array(
|
||||
'field' => 'name',
|
||||
'label' => _('Project name'),
|
||||
'rules' => 'required|min_length[3]|max_length[100]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'description',
|
||||
'label' => _('Description'),
|
||||
'rules' => 'required|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'defaultmodel',
|
||||
'label' => _('3D model'),
|
||||
'rules' => 'file_allowed_type[obj]',
|
||||
),
|
||||
array(
|
||||
'field' => 'defaultconfig',
|
||||
'label' => _('Default configuration'),
|
||||
'rules' => 'file_allowed_type[calc]',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for creating trials.
|
||||
*
|
||||
|
||||
@@ -35,6 +35,7 @@ class Trials extends CI_Controller {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('upload');
|
||||
$this->load->model('parameter');
|
||||
$this->load->model('program');
|
||||
$this->load->model('project');
|
||||
@@ -64,7 +65,17 @@ class Trials extends CI_Controller {
|
||||
|
||||
if ($this->form_validation->run('trials/create') === true) {
|
||||
// TODO: Handle file upload
|
||||
$config = array(
|
||||
'upload_path' => '/tmp',
|
||||
'allowed_types' => '*',
|
||||
'max_size' => ini_get('upload_max_filesize'),
|
||||
'file_name' => 'default',
|
||||
);
|
||||
$this->upload->initialize($config);
|
||||
|
||||
if (!$this->upload->do_upload('3dmodel')) {
|
||||
$this->messages->add(_('There was an error while uploading the selected 3d model.'), 'error');
|
||||
} else {
|
||||
$data = array(
|
||||
'name' => $this->input->post('name'),
|
||||
'description' => $this->input->post('description'),
|
||||
@@ -87,14 +98,22 @@ class Trials extends CI_Controller {
|
||||
$trialPath = FCPATH . 'uploads/' . $projectId . '/' . $trialId . '/';
|
||||
mkdirs($trialPath);
|
||||
|
||||
$this->load->library('job');
|
||||
$this->job->createConfigs($trialId);
|
||||
$model = $this->upload->data();
|
||||
if (!copy($model['full_path'], $trialPath . $model['file_name'])) {
|
||||
$this->messages->add(_('The selected 3d model could not be copied to trial path.'), 'error');
|
||||
}
|
||||
|
||||
//redirect('trials/detail/' . $trialId, 'refresh');
|
||||
$program = $this->program->getById($data['program_id']);
|
||||
|
||||
$this->load->library('program_runner', array('program_driver' => $program['driver']));
|
||||
$this->program_runner->createJob($trialId);
|
||||
|
||||
redirect('trials/detail/' . $trialId, 'refresh');
|
||||
} else {
|
||||
$this->messages->add(_('The trial could not be created.'), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = array(); // empty the data array
|
||||
$data['parameters'] = $parameters;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<h2><?=_('Create a new trial');?></h2>
|
||||
</div>
|
||||
|
||||
<form name="newTrial" method="post" action="<?=site_url('trials/create/' . $project['id']);?>">
|
||||
<form name="newTrial" method="post" action="<?=site_url('trials/create/' . $project['id']);?>" enctype="multipart/form-data">
|
||||
<div class="box">
|
||||
|
||||
<h3><?=_('Required information');?></h3>
|
||||
@@ -31,8 +31,7 @@
|
||||
<li>
|
||||
<h4><?=_('3D model');?></h4>
|
||||
<?
|
||||
$defaultmodel = 'foo';
|
||||
if (isset($defaultmodel)):
|
||||
if (file_exists(FCPATH.'uploads/'.$project['id'].'/default.txt')):
|
||||
?>
|
||||
<div class="notice">
|
||||
<strong><?=_('There is a default model set for this project.');?></strong><br />
|
||||
@@ -42,8 +41,9 @@
|
||||
endif;
|
||||
?>
|
||||
<div>
|
||||
<input type="file" class="file" name="defaultmodel" value="<?=set_value('defaultmodel');?>" />
|
||||
<?=form_error('defaultmodel');?>
|
||||
<input type="file" class="file" name="3dmodel" value="<?=set_value('3dmodel');?>" />
|
||||
<?=form_error('3dmodel');?>
|
||||
<?=$this->upload->display_errors('<span class="error">', '</span>');?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -53,7 +53,6 @@
|
||||
|
||||
<h3><?=_('Application-specific parameters');?></h3>
|
||||
<?
|
||||
$defaultconfig = 'foo';
|
||||
if (isset($defaultconfig)):
|
||||
?>
|
||||
<div class="notice">
|
||||
|
||||
Reference in New Issue
Block a user