diff --git a/stade/core/models/approach.py b/stade/core/models/approach.py
index 5c7aef49..4988ba14 100644
--- a/stade/core/models/approach.py
+++ b/stade/core/models/approach.py
@@ -77,3 +77,9 @@ def latest_successful_submission(self) -> Submission | None:
.order_by('-created')
.first()
)
+
+ @property
+ def manuscript_url(self):
+ if self.manuscript:
+ return self.manuscript.url
+ return None
diff --git a/stade/core/rest/__init__.py b/stade/core/rest/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/stade/core/rest/serializers.py b/stade/core/rest/serializers.py
deleted file mode 100644
index ba9fcedb..00000000
--- a/stade/core/rest/serializers.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from rest_framework import serializers
-
-from stade.core.models import Challenge, Task
-
-
-class TaskSerializer(serializers.ModelSerializer):
- class Meta:
- model = Task
- fields = ['id', 'name', 'type']
-
-
-class ChallengeSerializer(serializers.ModelSerializer):
- class Meta:
- model = Challenge
- fields = ['id', 'name', 'tasks']
-
- tasks = TaskSerializer(many=True, read_only=True)
-
-
-class LeaderboardEntrySerializer(serializers.Serializer):
- submission_id = serializers.IntegerField(source='id')
- approach_name = serializers.CharField(source='approach.name')
- approach_manuscript_url = serializers.SerializerMethodField()
- approach_uses_external_data = serializers.BooleanField(source='approach.uses_external_data')
- overall_score = serializers.FloatField()
- submission_created = serializers.DateTimeField(source='created')
- team_name = serializers.CharField(source='approach.team.name')
- team_institution_name = serializers.SerializerMethodField()
- team_institution_url = serializers.SerializerMethodField()
-
- def get_team_institution_url(self, submission):
- return (
- None
- if not submission.approach.team.institution_url
- else submission.approach.team.institution_url
- )
-
- def get_team_institution_name(self, submission):
- return (
- None
- if not submission.approach.team.institution
- else submission.approach.team.institution
- )
-
- def get_approach_manuscript_url(self, submission):
- if submission.approach.manuscript:
- return self.context['request'].build_absolute_uri(submission.approach.manuscript.url)
- else:
- # historical reasons, as well as the live challenge not requiring manuscripts
- return None
diff --git a/stade/core/rest/views.py b/stade/core/rest/views.py
deleted file mode 100644
index 5b951818..00000000
--- a/stade/core/rest/views.py
+++ /dev/null
@@ -1,68 +0,0 @@
-import logging
-
-from django.http import Http404, JsonResponse
-from django.shortcuts import get_object_or_404
-from rest_framework.decorators import api_view
-from rest_framework.pagination import LimitOffsetPagination
-from rest_framework.response import Response
-
-from stade.core.leaderboard import submissions_by_approach, submissions_by_team
-from stade.core.models import Challenge, Submission, Task
-from stade.core.rest.serializers import ChallengeSerializer, LeaderboardEntrySerializer
-
-logger = logging.getLogger(__name__)
-
-
-@api_view(['GET'])
-def challenge_detail(request, challenge_id):
- challenge = get_object_or_404(Challenge, pk=challenge_id)
- serializer = ChallengeSerializer(challenge)
- return Response(serializer.data)
-
-
-@api_view(['GET'])
-def leaderboard(request, task_id, cluster):
- if request.user.is_staff:
- task = get_object_or_404(Task, pk=task_id)
- else:
- task = get_object_or_404(Task.objects.filter(scores_published=True), pk=task_id)
-
- paginator = LimitOffsetPagination()
- paginator.default_limit = paginator.max_limit = 200
-
- if cluster == 'approach':
- submission_ids = submissions_by_approach(task.id)
- elif cluster == 'team':
- submission_ids = submissions_by_team(task.id)
- else:
- raise Http404()
-
- leaderboard_submissions = (
- Submission.objects.select_related('approach', 'approach__team')
- .filter(id__in=submission_ids)
- .order_by('-overall_score', 'created')
- )
-
- result_page = paginator.paginate_queryset(leaderboard_submissions, request)
- serializer = LeaderboardEntrySerializer(result_page, many=True, context={'request': request})
-
- return paginator.get_paginated_response(serializer.data)
-
-
-@api_view(['GET'])
-def submission_scores(request, submission_id):
- if request.user.is_staff:
- # Remove all deferred fields, since we want the score immediately
- submission = get_object_or_404(Submission.objects.defer(None), pk=submission_id)
- else:
- # Remove all deferred fields, since we want the score immediately
- submission = get_object_or_404(
- Submission.objects.defer(None).filter(approach__task__scores_published=True),
- pk=submission_id,
- )
-
- if isinstance(submission.score, list) or submission.score is None:
- logger.warning('Unable to serialize submission score')
- return JsonResponse({})
-
- return JsonResponse(submission.score)
diff --git a/stade/core/templates/leaderboards.html b/stade/core/templates/leaderboards.html
index e5e4b5ca..4a50a5d1 100644
--- a/stade/core/templates/leaderboards.html
+++ b/stade/core/templates/leaderboards.html
@@ -1,15 +1,561 @@
{% extends "base.html" %}
+{% load static %}
{% block extra_head %}
-
-
-
+
+
+
+
{% endblock %}
{% block content %}
-
| + Rank + {{ stats.total_submissions }} total + | ++ Team + {{ stats.unique_teams }} unique teams + | +Approach | +Manuscript | ++ Used External Data + {{ stats.used_external_data }} yes + | ++ Primary Metric Value + {% if active_task.type == 'segmentation' %}Jaccard Index{% else %}{{ active_task.get_metric_field_display }}{% endif %} + | ++ | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ forloop.counter }} | +
+ {{ submission.approach.team.name }}
+ {% if submission.approach.team.institution %}
+
+ {{ submission.approach.team.institution }}
+
+ {% endif %}
+ |
+ {{ submission.approach.name }} | ++ {% if submission.approach.manuscript_url %} + + description + + {% else %} + - + {% endif %} + | +
+ {% if submission.approach.uses_external_data %}
+
+ public
+ Yes
+
+ {% else %}
+
+ public_off
+ No
+
+ {% endif %}
+ |
+ {{ submission.overall_score|floatformat:3 }} | ++ {% if active_task.type != 'segmentation' %} + + {% endif %} + | +|||||||||||||
|
+
+ {% if active_task.type == 'classification' %}
+
+
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |||||||||||||||||||
No submissions found for this task.
+No tasks available for this challenge.
+