Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/apps/api/serializers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from competitions.models import PhaseTaskInstance, Phase
from datasets.models import Data
from tasks.models import Task, Solution
from competitions.models import Competition


class SolutionSerializer(WritableNestedModelSerializer):
Expand Down Expand Up @@ -138,7 +139,12 @@ class Meta:
)

def get_competitions(self, instance):
return self.context['task_titles'][instance.pk]

# Fech competitions which hase phases with this task
# competitions = Phase.objects.filter(tasks__in=[instance.pk]).values('competition')
competitions = Competition.objects.filter(phases__tasks__in=[instance.pk]).values("id", "title").distinct()

return competitions

def get_shared_with(self, instance):
return self.context['shared_with'][instance.pk]
Expand Down
19 changes: 19 additions & 0 deletions src/apps/datasets/migrations/0006_auto_20230528_0829.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.17 on 2023-05-28 08:29

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('datasets', '0005_auto_20230527_0837'),
]

operations = [
migrations.AlterField(
model_name='data',
name='competition',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='submission', to='competitions.Competition'),
),
]
2 changes: 1 addition & 1 deletion src/apps/datasets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def in_use(self):
Q(phases__tasks__input_data=self) |
Q(phases__tasks__reference_data=self) |
Q(phases__tasks__scoring_program=self)
).values_list('pk', flat=True).distinct()
).values('pk', 'title').distinct()
return competitions_in_use

def __str__(self):
Expand Down
54 changes: 25 additions & 29 deletions src/static/riot/datasets/management.tag
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<data-management>
<!-------------------------------------
Search and filter bits
-------------------------------------->
<!-- Search and filter bits -->

<div class="ui icon input">
<input type="text" placeholder="Search..." ref="search" onkeyup="{ filter.bind(this, undefined) }">
Expand All @@ -18,21 +16,18 @@
</div>
<button class="ui green right floated labeled icon button" onclick="{show_creation_modal}">
<i selenium="add-dataset" class="plus icon"></i>
Add Dataset
Add Dataset/Program
</button>
<button class="ui red right floated labeled icon button {disabled: marked_datasets.length === 0}" onclick="{delete_datasets}">
<i class="icon delete"></i>
Delete Selected Datasets
</button>

<!-------------------------------------
Data Table
-------------------------------------->
<!-- Data Table -->
<table class="ui {selectable: datasets.length > 0} celled compact table">
<thead>
<tr>
<th>File Name</th>
<th>Competition in</th>
<th width="175px">Type</th>
<th width="175px">Size</th>
<th width="125px">Uploaded</th>
Expand All @@ -46,12 +41,7 @@
<tr each="{ dataset, index in datasets }"
class="dataset-row"
onclick="{show_info_modal.bind(this, dataset)}">
<!-- show file name if exists otherwise show name(for old submissions) -->
<td>{ dataset.file_name || dataset.name }</td>
<!-- show compeition name as link if competition is available -->
<td if="{dataset.competition}"><a class="link-no-deco" target="_blank" href="../competitions/{ dataset.competition.id }">{ dataset.competition.title }</a></td>
<!-- show empty td if competition is not available -->
<td if="{!dataset.competition}"></td>
<td>{ dataset.name }</td>
<td>{ dataset.type }</td>
<td>{ format_file_size(dataset.file_size) }</td>
<td>{ timeSince(Date.parse(dataset.created_when)) } ago</td>
Expand Down Expand Up @@ -82,11 +72,9 @@
</tbody>
<tfoot>

<!-------------------------------------
Pagination
-------------------------------------->
<!-- Pagination -->
<tr>
<th colspan="9" if="{datasets.length > 0}">
<th colspan="8" if="{datasets.length > 0}">
<div class="ui right floated pagination menu" if="{datasets.length > 0}">
<a show="{!!_.get(pagination, 'previous')}" class="icon item" onclick="{previous_page}">
<i class="left chevron icon"></i>
Expand All @@ -103,9 +91,10 @@
</tfoot>
</table>

<!-- Dataset Detail Model -->
<div ref="info_modal" class="ui modal">
<div class="header">
{selected_row.file_name || selected_row.name}
{selected_row.name}
</div>
<div class="content">
<h3>Details</h3>
Expand All @@ -114,7 +103,6 @@
<thead>
<tr>
<th>Key</th>
<th>Competition in</th>
<th>Created By</th>
<th>Created</th>
<th>Type</th>
Expand All @@ -124,10 +112,6 @@
<tbody>
<tr>
<td>{selected_row.key}</td>
<!-- show compeition name as link if competition is available -->
<td if="{selected_row.competition}"><a class="link-no-deco" target="_blank" href="../competitions/{ selected_row.competition.id }">{ selected_row.competition.title }</a></td>
<!-- show empty td if competition is not available -->
<td if="{!selected_row.competition}"></td>
<td>{selected_row.created_by}</td>
<td>{pretty_date(selected_row.created_when)}</td>
<td>{_.startCase(selected_row.type)}</td>
Expand All @@ -143,8 +127,8 @@
</virtual>
<div show="{!!_.get(selected_row.in_use, 'length')}"><strong>Used by:</strong>
<div class="ui bulleted list">
<div class="item" each="{id in selected_row.in_use}">
<a href="{URLS.COMPETITION_DETAIL(id)}" target="_blank">Benchmark id: {id}</a>
<div class="item" each="{comp in selected_row.in_use}">
<a href="{URLS.COMPETITION_DETAIL(comp.pk)}" target="_blank">{comp.title}</a>
</div>
</div>
</div>
Expand All @@ -161,9 +145,9 @@
</div>
</div>


<!-- Add Dataset Model -->
<div ref="dataset_creation_modal" class="ui modal">
<div class="header">Form</div>
<div class="header">Add Dataset/Program Form</div>

<div class="content">
<div class="ui message error" show="{ Object.keys(errors).length > 0 }">
Expand Down Expand Up @@ -209,6 +193,7 @@
<button class="ui basic red cancel button">Cancel</button>
</div>
</div>

<script>
var self = this
self.mixin(ProgressBarMixin)
Expand All @@ -223,7 +208,6 @@
"reference_data",
"scoring_program",
"starting_kit",
"submission",
]
self.errors = []
self.datasets = []
Expand Down Expand Up @@ -299,6 +283,7 @@
CODALAB.api.get_datasets(filters)
.done(function (data) {
self.datasets = data.results
self.datasets = self.filter_out_submissions(self.datasets)
self.pagination = {
"count": data.count,
"next": data.next,
Expand Down Expand Up @@ -457,6 +442,17 @@
}
}

// Function to remove submissions from datasets
self.filter_out_submissions = function(datasets) {
datasets_to_return = []
datasets.forEach(dataset => {
if (dataset.type != "submission"){
datasets_to_return.push(dataset)
}
})
return datasets_to_return
}

// Function to format file size
self.format_file_size = function(file_size) {
// parse file size from string to float
Expand Down
8 changes: 6 additions & 2 deletions src/static/riot/management.tag
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<!--Todo: ultimately decide whether this belongs on tasks:management or dataset:management
Is currently at both locations-->
<div class="ui top attached tabular menu">
<div class="active item" data-tab="datasets">Datasets and programs</div>
<div class="active item" data-tab="submissions">Submissions</div>
<div class="item" data-tab="datasets">Datasets and programs</div>
<div class="item" data-tab="tasks">Tasks</div>
<div class="right menu">
<div class="item">
Expand All @@ -12,7 +13,10 @@
</div>
</div>
</div>
<div class="ui active bottom attached tab segment" data-tab="datasets">
<div class="ui active bottom attached tab segment" data-tab="submissions">
<submission-management></submission-management>
</div>
<div class="ui bottom attached tab segment" data-tab="datasets">
<data-management></data-management>
</div>
<div class="ui bottom attached tab segment" data-tab="tasks">
Expand Down
Loading