Modified some views, routes and models to work with the new many-to-many for tests and benchmarks
This commit is contained in:
parent
15377da52d
commit
f27490e192
@ -47,9 +47,13 @@ class TestController extends Controller {
|
|||||||
$test = new Test;
|
$test = new Test;
|
||||||
$test->title = $params['test_title'];
|
$test->title = $params['test_title'];
|
||||||
$test->description = $params['test_description'];
|
$test->description = $params['test_description'];
|
||||||
$test->benchmark_id = $params['test_benchmark'];
|
|
||||||
$test->component_id = $params['test_component'];
|
$test->component_id = $params['test_component'];
|
||||||
|
|
||||||
|
// attach benchmarks to test
|
||||||
|
foreach ($params['test_benchmarks'] as $b) {
|
||||||
|
$test->benchmarks()->attach($b);
|
||||||
|
}
|
||||||
|
|
||||||
$test->save();
|
$test->save();
|
||||||
|
|
||||||
// redirect the user back to the home page
|
// redirect the user back to the home page
|
||||||
|
@ -13,7 +13,7 @@ class Benchmark extends Model {
|
|||||||
];
|
];
|
||||||
|
|
||||||
public function tests() {
|
public function tests() {
|
||||||
return $this->hasMany(Test::class);
|
return $this->belongsToMany(Test::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ class Test extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function benchmark() {
|
public function benchmark() {
|
||||||
return $this->belongsTo(Benchmark::class);
|
return $this->belongsToMany(Benchmark::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function component() {
|
public function component() {
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
<div class="four columns">
|
<div class="four columns">
|
||||||
<label>
|
<label>
|
||||||
Benchmark:
|
Benchmarks:
|
||||||
<select class="u-full-width" name="test_benchmark">
|
<select class="u-full-width" name="test_benchmarks" multiple>
|
||||||
{% for b in benchmarks %}
|
{% for b in benchmarks %}
|
||||||
<option value="{{ b.id }}">{{ b.name }}</option>
|
<option value="{{ b.id }}">{{ b.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -10,9 +10,8 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Test title</th>
|
<th>Test title</th>
|
||||||
<th>Benchmark</th>
|
|
||||||
<th>Hardware</th>
|
<th>Hardware</th>
|
||||||
<th># of Results</th>
|
<th># of benchmarks</th>
|
||||||
<th>Last updated</th>
|
<th>Last updated</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -20,9 +19,8 @@
|
|||||||
{% for t in tests %}
|
{% for t in tests %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url_for('test.view', { test_id: t.id }) }}">{{ t.title }}</a></td>
|
<td><a href="{{ url_for('test.view', { test_id: t.id }) }}">{{ t.title }}</a></td>
|
||||||
<td>{{ t.benchmark.name }}</td>
|
|
||||||
<td>{{ t.component.name }}</td>
|
<td>{{ t.component.name }}</td>
|
||||||
<td>{{ t.results | length }}</td>
|
<td>{{ t.benchmarks() | length }}</td>
|
||||||
<td>{{ t.updated_at | date("F jS \\a\\t g:ia") }}</td>
|
<td>{{ t.updated_at | date("F jS \\a\\t g:ia") }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
<div class="twelve columns">
|
<div class="twelve columns">
|
||||||
<h1>{{ test.title }}</h1>
|
<h1>{{ test.title }}</h1>
|
||||||
<p>{{ test.description }}</p>
|
<p>{{ test.description }}</p>
|
||||||
|
<ul>
|
||||||
|
{% for b in test.benchmarks %}
|
||||||
|
<li>{{ b.name }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -33,8 +38,8 @@
|
|||||||
{% for r in test.results %}
|
{% for r in test.results %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ test.component().name }}</td>
|
<td>{{ test.component().name }}</td>
|
||||||
<td>{{ test.benchmark().name }}</td>
|
<td>{{ r.benchmark().name }}</td>
|
||||||
<td>{{ test.scoring | capitalize }}</td>
|
<td>{{ r.benchmark().scoring | capitalize }}</td>
|
||||||
<td>{{ r.average }}</td>
|
<td>{{ r.average }}</td>
|
||||||
<td>{{ r.minimum ? r.minimum : 'N/a' }}</td>
|
<td>{{ r.minimum ? r.minimum : 'N/a' }}</td>
|
||||||
<td>{{ r.maximum ? r.maximum : 'N/a' }}</td>
|
<td>{{ r.maximum ? r.maximum : 'N/a' }}</td>
|
||||||
@ -43,7 +48,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>There are no results associated with this.</p>
|
<p>There are no results associated with this test.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user