Skip to content

Commit

Permalink
Merge branch 'main' into 3592-code-blocks-buggy-in-markdown-renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn committed Jan 7, 2025
2 parents edae00c + 3cc3ba9 commit e45d3bb
Show file tree
Hide file tree
Showing 23 changed files with 855 additions and 770 deletions.
1 change: 0 additions & 1 deletion app/grandchallenge/challenges/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class ChallengeRequestAdmin(ModelAdmin):
"created",
"status",
"total_cost",
"budget_for_hosting_challenge",
)
actions = ["create_challenge", "send_status_update_email"]
list_filter = ["status"]
Expand Down
3 changes: 0 additions & 3 deletions app/grandchallenge/challenges/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class Meta:
"algorithm_outputs",
*phase_1_items,
*phase_2_items,
"budget_for_hosting_challenge",
"challenge_fee_agreement",
"comments",
)
Expand All @@ -200,7 +199,6 @@ class Meta:
"data_license": "We agree to publish the data set for this challenge under a CC-BY license.",
"phase_1_number_of_submissions_per_team": "Expected number of submissions per team to Phase 1",
"phase_2_number_of_submissions_per_team": "Expected number of submissions per team to Phase 2",
"budget_for_hosting_challenge": "Budget for hosting challenge in Euros",
"inference_time_limit_in_minutes": "Average algorithm job run time in minutes",
"algorithm_maximum_settable_memory_gb": "Maximum memory for algorithm jobs in GB",
"structured_challenge_submission_doi": "DOI",
Expand Down Expand Up @@ -454,7 +452,6 @@ def __init__(self, creator, *args, **kwargs):
*phase_2_items,
css_class="border rounded px-4 pt-4 my-5",
),
"budget_for_hosting_challenge",
"challenge_fee_agreement",
"comments",
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.17 on 2024-12-19 11:46

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
(
"challenges",
"0045_challengerequest_algorithm_maximum_settable_memory_gb_and_more",
),
]

operations = [
migrations.RemoveField(
model_name="challengerequest",
name="budget_for_hosting_challenge",
),
]
3 changes: 0 additions & 3 deletions app/grandchallenge/challenges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,6 @@ class ChallengeRequestStatusChoices(models.TextChoices):
"phase 1 and 2 cost estimates by the number of tasks.",
validators=[MinValueValidator(limit_value=1)],
)
budget_for_hosting_challenge = models.PositiveIntegerField(
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(
default=False,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ <h3>[{{ object.short_name }}] {{ object.title }}</h3>
{% else %}
<tr><td class="font-weight-bold">Public data license</td> <td><i class="fas fa-exclamation-circle text-danger pr-2"></i> The organizers do not agree to publish their public data set under a CC-BY license for the following reason: <br> <span class="ml-4">{{ object.data_license_extra }}</span></td></tr>
{% endif %}
<tr><td class="font-weight-bold">Organizer's budget for hosting challenge</td> <td>{{ object.budget_for_hosting_challenge }} €</td></tr>
{% if object.comments %}
<tr><td class="font-weight-bold">Comments from organizers</td> <td><div class="bg-warning rounded p-3">{{ object.comments|linebreaks }}</div></td></tr>
{% endif %}
Expand Down
18 changes: 14 additions & 4 deletions app/grandchallenge/core/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from distutils.util import strtobool as strtobool_i
from functools import wraps


Expand All @@ -16,6 +15,17 @@ def wrapper(*args, **kwargs):
return wrapper


def strtobool(val) -> bool:
"""Return disutils.util.strtobool as a boolean."""
return bool(strtobool_i(val))
def strtobool(val):
"""Convert a string representation of truth to true or false.
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ("y", "yes", "t", "true", "on", "1"):
return True
elif val in ("n", "no", "f", "false", "off", "0"):
return False
else:
raise ValueError(f"invalid truth value {val}")
19 changes: 14 additions & 5 deletions app/grandchallenge/documentation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from crispy_forms.layout import Submit
from django import forms

from grandchallenge.core.widgets import MarkdownEditorInlineWidget
from grandchallenge.core.forms import SaveFormInitMixin
from grandchallenge.core.widgets import MarkdownEditorFullPageWidget
from grandchallenge.documentation.models import DocPage


Expand All @@ -14,13 +15,21 @@ def __init__(self, *args, **kwargs):

class Meta:
model = DocPage
fields = ("title", "content", "parent")
widgets = {"content": MarkdownEditorInlineWidget}
fields = ("title", "parent")


class DocPageUpdateForm(DocPageCreateForm):
"""Like the create form but you can also move the page."""
class DocPageMetadataUpdateForm(DocPageCreateForm):
"""Like the create form, but you can also move the page."""

position = forms.IntegerField()
position.label = "Move to index position"
position.required = False


class DocPageContentUpdateForm(SaveFormInitMixin, forms.ModelForm):
class Meta:
model = DocPage
fields = ("content",)
widgets = {
"content": MarkdownEditorFullPageWidget,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "documentation/docpage_form.html" %}
{% load crispy from crispy_forms_tags %}

{% block container %}container-fluid{% endblock %}

{% block outer_content %}

<h2>Update Page</h2>

{% crispy form %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,14 @@
<div class="row mt-3">
<div class="col-12 col-sm-6 col-md-7 d-inline-block text-left">
{% if 'documentation.change_docpage' in perms %}
<a class="btn btn-md btn-outline-dark d-inline-flex" href="{% url 'documentation:list' %}">Page overview</a>
<a class="btn btn-md btn-outline-dark d-inline-flex" href="{% url 'documentation:create' %}">Add</a>
<a class="btn btn-md btn-outline-dark" href="{% url 'documentation:update' slug=currentdocpage.slug %}">Edit</a>
<a class="btn btn-md btn-outline-dark" href="{% url 'documentation:list' %}">Page overview</a>
<a class="btn btn-md btn-outline-dark" href="{% url 'documentation:create' %}">Add</a>
<a class="btn btn-md btn-outline-dark" href="{% url 'documentation:content-update' slug=currentdocpage.slug %}" title="Edit page">
<i class="fas fa-edit"></i>
</a>
<a class="btn btn-md btn-outline-dark" href="{% url 'documentation:metadata-update' slug=currentdocpage.slug %}" title="Edit metadata">
<i class="fas fa-tools"></i>
</a>
{% endif %}
</div>
<div class="col-12 col-sm-6 col-md-5 justify-content-start justify-content-sm-end form-inline">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ <h2>Documentation Pages</h2>
</td>
{% if 'documentation.change_docpage' in perms %}
<td>
<a href="{% url 'documentation:update' slug=page.slug %}"><i class="fa fa-cog text-primary" aria-hidden="true"></i></a>
<a class="text-primary" title="Edit Page" href="{% url 'documentation:content-update' slug=page.slug %}"><i class="fa fa-edit"></i></a>
<a class="text-primary" title="Edit Metadata" href="{% url 'documentation:metadata-update' slug=page.slug %}"><i class="fa fa-tools"></i></a>
</td>
{% endif %}
</tr>
Expand Down
15 changes: 13 additions & 2 deletions app/grandchallenge/documentation/urls.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
from django.urls import path

from grandchallenge.documentation.views import (
DocPageContentUpdate,
DocPageCreate,
DocPageDetail,
DocPageList,
DocPageUpdate,
DocPageMetadataUpdate,
DocumentationHome,
)

app_name = "documentation"


urlpatterns = [
path("", DocumentationHome.as_view(), name="home"),
path("overview/", DocPageList.as_view(), name="list"),
path("create/", DocPageCreate.as_view(), name="create"),
path("<slug:slug>/", DocPageDetail.as_view(), name="detail"),
path("<slug:slug>/update/", DocPageUpdate.as_view(), name="update"),
path(
"<slug:slug>/content-update/",
DocPageContentUpdate.as_view(),
name="content-update",
),
path(
"<slug:slug>/metadata-update/",
DocPageMetadataUpdate.as_view(),
name="metadata-update",
),
]
31 changes: 27 additions & 4 deletions app/grandchallenge/documentation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
from guardian.mixins import LoginRequiredMixin

from grandchallenge.documentation.forms import (
DocPageContentUpdateForm,
DocPageCreateForm,
DocPageUpdateForm,
DocPageMetadataUpdateForm,
)
from grandchallenge.documentation.models import DocPage
from grandchallenge.subdomains.utils import reverse_lazy
from grandchallenge.subdomains.utils import reverse, reverse_lazy


class DocPageList(ListView):
Expand Down Expand Up @@ -72,9 +73,11 @@ def get_object(self, queryset=None):
return get_object_or_404(DocPage, order=1)


class DocPageUpdate(LoginRequiredMixin, PermissionRequiredMixin, UpdateView):
class DocPageMetadataUpdate(
LoginRequiredMixin, PermissionRequiredMixin, UpdateView
):
model = DocPage
form_class = DocPageUpdateForm
form_class = DocPageMetadataUpdateForm
permission_required = "documentation.change_docpage"
raise_exception = True
login_url = reverse_lazy("account_login")
Expand All @@ -85,9 +88,29 @@ def form_valid(self, form):
return response


class DocPageContentUpdate(
LoginRequiredMixin, PermissionRequiredMixin, UpdateView
):
model = DocPage
form_class = DocPageContentUpdateForm
template_name_suffix = "_content_update"
permission_required = "documentation.change_docpage"
raise_exception = True
login_url = reverse_lazy("account_login")


class DocPageCreate(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
model = DocPage
form_class = DocPageCreateForm
permission_required = "documentation.add_docpage"
raise_exception = True
login_url = reverse_lazy("account_login")

def get_success_url(self):
"""On successful creation, go to content update."""
return reverse(
"documentation:content-update",
kwargs={
"slug": self.object.slug,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<tr>
<th>Created</th>
<th>Updated</th>
<th>Evaluation</th>
<th>Submission</th>
<th class="nonSortable">Evaluation</th>
<th class="nonSortable">Submission</th>
<th>Status</th>
<th>Result</th>
<th class="nonSortable">Result</th>
</tr>
</thead>
<tbody>
Expand All @@ -29,8 +29,6 @@
{% endif %}
</td>
</tr>
{% empty %}
<tr><td colspan="100%" class="text-center">No evaluations</td></tr>
{% endfor %}
</tbody>
</table>
Expand Down
Loading

0 comments on commit e45d3bb

Please sign in to comment.