Skip to content

Commit

Permalink
Merge branch 'feat_optional_inputs' into job_create_for_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
amickan committed Dec 18, 2024
2 parents 36f51e6 + 275bad5 commit ec37b69
Show file tree
Hide file tree
Showing 45 changed files with 404 additions and 415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h2>Admins for {{ challenge.short_name }}</h2>
{% endblock %}

{% block tableExtraHeaders %}
<th>Remove</th>
<th class="nonSortable">Remove</th>
{% endblock tableExtraHeaders %}

{% block tableExtraBody %}
Expand Down
8 changes: 8 additions & 0 deletions app/grandchallenge/algorithms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,14 @@ def __init__(self, *args, algorithm, **kwargs):
if not self._algorithm.default_interface:
self.fields["set_as_default"].initial = True

def clean_set_as_default(self):
set_as_default = self.cleaned_data["set_as_default"]

if not set_as_default and not self._algorithm.default_interface:
raise ValidationError("Your algorithm needs a default interface.")

return set_as_default

def clean(self):
cleaned_data = super().clean()

Expand Down
6 changes: 6 additions & 0 deletions app/grandchallenge/algorithms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,12 @@ class Meta:
def __str__(self):
return str(self.interface)

def clean(self):
super().clean()

if not self.is_default and not self.algorithm.default_interface:
raise ValidationError("This algorithm needs a default interface.")


class AlgorithmUserObjectPermission(UserObjectPermissionBase):
content_object = models.ForeignKey(Algorithm, on_delete=models.CASCADE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2>Permission Requests for {{ algorithm.title }}</h2>
<th>Department</th>
<th>Location</th>
<th>Website</th>
<th>Status</th>
<th class="nonSortable">Status</th>
</tr>
</thead>
<tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2>Permission Requests for {{ archive.title }}</h2>
<th>Department</th>
<th>Location</th>
<th>Website</th>
<th>Status</th>
<th class="nonSortable">Status</th>
</tr>
</thead>
<tbody>
Expand Down
37 changes: 0 additions & 37 deletions app/grandchallenge/challenges/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,43 +193,6 @@ class Meta:
widgets = {
"start_date": forms.TextInput(attrs={"type": "date"}),
"end_date": forms.TextInput(attrs={"type": "date"}),
"long_term_commitment": forms.CheckboxInput(
attrs={
"onchange": "updateExtraField('long_term_commitment', 'support this challenge long-term');"
}
),
"data_license": forms.CheckboxInput(
attrs={
"onchange": "updateExtraField('data_license', 'use a CC-BY license for your data');"
}
),
"expected_number_of_teams": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"number_of_tasks": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"average_size_of_test_image_in_mb": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"inference_time_limit_in_minutes": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"phase_1_number_of_submissions_per_team": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"phase_2_number_of_submissions_per_team": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"phase_1_number_of_test_images": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"phase_2_number_of_test_images": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
"budget_for_hosting_challenge": forms.NumberInput(
attrs={"oninput": "validity.valid||(value='');"}
),
}
labels = {
"short_name": "Acronym",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class Migration(migrations.Migration):
model_name="challengerequest",
name="budget_for_hosting_challenge",
field=models.PositiveIntegerField(
default=0,
help_text="What is your budget for hosting this challenge? Please be reminded of our <a href='/challenge-policy-and-pricing/'>challenge pricing policy</a>.",
),
),
Expand Down
1 change: 0 additions & 1 deletion app/grandchallenge/challenges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,6 @@ class ChallengeRequestStatusChoices(models.TextChoices):
validators=[MinValueValidator(limit_value=1)],
)
budget_for_hosting_challenge = models.PositiveIntegerField(
default=0,
help_text="What is your budget for hosting this challenge? Please be reminded of our <a href='/challenge-policy-and-pricing/'>challenge pricing policy</a>.",
)
long_term_commitment = models.BooleanField(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
document.addEventListener("DOMContentLoaded", event => {
$("#challengeCostsOverviewTable").DataTable({
order: [[2, "desc"]],
order: [
[2, "desc"],
[3, "desc"],
],
lengthChange: false,
pageLength: 100,
columnDefs: [
{
targets: "datatables-non-sortable",
searchable: false,
orderable: false,
},
],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,22 @@ function updateExtraField(fieldName, helpText) {
}
}

$(document).ready(() => {
document.addEventListener("DOMContentLoaded", () => {
const longTermCommitmentCheckbox = document.getElementById(
"id_long_term_commitment",
);
longTermCommitmentCheckbox.addEventListener("change", () => {
updateExtraField(
"long_term_commitment",
"support this challenge long-term",
);
});

const dataLicenseCheckbox = document.getElementById("id_data_license");
dataLicenseCheckbox.addEventListener("change", () => {
updateExtraField("data_license", "use a CC-BY license for your data");
});

updateExtraField(
"long_term_commitment",
"support this challenge long-term",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,5 @@ document.addEventListener("DOMContentLoaded", event => {
$("#challengeRequestsTable").DataTable({
order: [[3, "desc"]],
lengthChange: false,
pageLength: 50,
columnDefs: [
{
targets: "datatables-non-sortable",
searchable: false,
orderable: false,
},
],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ <h2>Request a Challenge</h2>

{% block script %}
{{ block.super }}
<script type="text/javascript" src="{% static "js/challenges/challenge_request_dynamic_fields.js" type="module" defer %}"></script>
<script type="module" src="{% static "js/challenges/challenge_request_dynamic_fields.mjs" %}"></script>
<script type="text/javascript" src="{% static "js/unsavedform.js" %}"></script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>{% if not perms.challenges.change_challengerequest %}Your{% endif %} Challen
<table class="table table-hover table-borderless table-sm w-100" id="challengeRequestsTable">
<thead class="thead-light">
<tr>
<th class="datatables-non-sortable"></th>
<th class="nonSortable"></th>
<th class="text-center">Acronym</th>
<th class="text-center">Creator</th>
<th class="text-center">Planned start date</th>
Expand Down
3 changes: 0 additions & 3 deletions app/grandchallenge/challenges/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ def get_queryset(self):
.with_available_compute()
.with_most_recent_submission_datetime()
.prefetch_related("phase_set")
.order_by(
F("most_recent_submission_datetime").desc(nulls_last=True)
)
)


Expand Down
8 changes: 8 additions & 0 deletions app/grandchallenge/core/static/css/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $pagination-disabled-bg: lighten($blue, 15%) !default;
@import "../vendored/bootswatch/dist/flatly/variables";
@import "../vendored/bootstrap/scss/bootstrap";
@import "../vendored/bootswatch/dist/flatly/bootswatch";
@import "datatables";

// Fix https://github.com/comic/grand-challenge.org/issues/1201
.custom-select {
Expand All @@ -42,3 +43,10 @@ $pagination-disabled-bg: lighten($blue, 15%) !default;
.btn {
margin: $btn-focus-width;
}

blockquote {
padding: 0 $spacer;
font-size: inherit !important;
border-left: $spacer * .25 solid $primary;
color: $primary;
}
25 changes: 25 additions & 0 deletions app/grandchallenge/core/static/css/datatables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

.dt-layout-start,
.dt-layout-end {
padding-top: $spacer * 0.5;
padding-bottom: $spacer * 0.5;
}

.dt-container ul.pagination {
justify-content: right;
}

.dt-layout-full,
.dt-layout-start,
.dt-layout-end {
padding-left: 0 !important;
padding-right: 0 !important;
}

.dt-scroll-body {
border-bottom: none !important;
}

.dt-orderable-none .dt-column-order {
display: none;
}
38 changes: 35 additions & 3 deletions app/grandchallenge/core/static/js/datatables.defaults.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
$.extend(true, DataTable.defaults, {
$.extend($.fn.dataTable.defaults, {
scrollX: true,
lengthChange: false,
language: {
paginate: {
next: "Next",
previous: "Previous",
},
},
pagingType: "simple_numbers",
columnDefs: [
{
// Prevents unexpected styling for dt-*-type datatypes
// Only applies to client-side tables
type: "string",
targets: "_all",
},
{
targets: "nonSortable",
searchable: false,
orderable: false,
},
],
drawCallback: function () {
const api = this.api();
api.columns().every(function () {
if (this.orderable) {
this.header().setAttribute(
"title",
"Activate to sort. Hold Shift to sort by multiple columns.",
);
}
});
},
});

$(document).on("init.dt", () => {
// Set up floating scroll, note that the target class only shows up when scrollX is set to true
$(".dataTables_scrollBody").floatingScroll();
const element = $(".dt-scroll-body");

if (element.length === 0) {
console.warn(
"Warning: Element for floating-scroll attachment could not be located",
);
}

element.floatingScroll();
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,5 @@ $(document).ready(() => {
[0, "desc"],
],
pageLength: 25,
columnDefs: [
{
targets: [-1],
searchable: false,
orderable: false,
},
],
});
});
11 changes: 4 additions & 7 deletions app/grandchallenge/core/static/js/sort_tables.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
$(document).ready(() => {
$("table.sortable").dataTable({
bJQueryUI: false,
sPaginationType: "full_numbers",
bPaginate: false,
bLengthChange: false,
bFilter: false,
bInfo: false,
bAutoWidth: false,
paginate: false,
lengthChange: false,
filter: false,
info: false,
});
});
6 changes: 1 addition & 5 deletions app/grandchallenge/datatables/static/js/datatables/list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ document.addEventListener("DOMContentLoaded", () => {
pageLength: 25,
serverSide: true,
columnDefs: [
{
targets: "nonSortable",
searchable: false,
orderable: false,
},
...$.fn.dataTable.defaults.columnDefs,
{
className: `align-middle text-${textAlign}`,
targets: "_all",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@
{% if search_results %}
{% for result in search_results %}
<div class="card rounded border-light my-1">
<a href="{% url 'documentation:detail' slug=result.slug %}"><h5 class="pl-3 pt-3">{{ result.title }}</h5></a>
<div class="mb-3 pl-3">{{ result.headline|clean }}</div>
<a href="{% url 'documentation:detail' slug=result.slug %}"><h5 class="p-3 m-0">{{ result.title }}</h5></a>
</div>
{% endfor %}
{% else %}
Expand Down
5 changes: 1 addition & 4 deletions app/grandchallenge/documentation/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.postgres.search import (
SearchHeadline,
SearchQuery,
SearchRank,
SearchVector,
Expand Down Expand Up @@ -44,10 +43,8 @@ def get_context_data(self, **kwargs):
if keywords:
query = SearchQuery(keywords)
vector = SearchVector("title", "content")
headline = SearchHeadline("content", query)
qs = (
qs.annotate(headline=headline)
.annotate(rank=SearchRank(vector, query))
qs.annotate(rank=SearchRank(vector, query))
.annotate(
similarity=TrigramSimilarity("title", keywords)
+ TrigramSimilarity("content", keywords)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ document.addEventListener("DOMContentLoaded", event => {
[2, "asc"],
],
lengthChange: false,
pageLength: 50,
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
$(document).ready(() => {
$("#groundtruthsTable").DataTable({
columnDefs: [
{
targets: "nonSortable",
searchable: false,
orderable: false,
},
],
});
$("#groundtruthsTable").DataTable();
});
Loading

0 comments on commit ec37b69

Please sign in to comment.