Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 1, 2024
1 parent 48047e4 commit bcc127a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 44 deletions.
10 changes: 2 additions & 8 deletions frx_challenges/frx_challenges/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,8 @@
}

EVALUATION_DISPLAY_CONFIG = [
{
"result_key": "chars",
"display_name": "Characters"
},
{
"result_key": "lines",
"display_name": "Lines"
}
{"result_key": "chars", "display_name": "Characters"},
{"result_key": "lines", "display_name": "Lines"},
]

django_yamlconf.load()
Expand Down
2 changes: 1 addition & 1 deletion frx_challenges/web/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def site_display_settings(request):
"site_footer_html": settings.SITE_FOOTER_HTML,
"site_page_header_image_url": settings.SITE_PAGE_HEADER_IMAGE_URL,
"challenge_state": settings.CHALLENGE_STATE,
"evaluation_display_config": settings.EVALUATION_DISPLAY_CONFIG
"evaluation_display_config": settings.EVALUATION_DISPLAY_CONFIG,
}
12 changes: 7 additions & 5 deletions frx_challenges/web/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations

from typing import List, Optional

from django.conf import settings
from django.contrib.auth.models import User
from django.db import models, transaction
from django_jsonform.models.fields import JSONField
from typing import Optional, List

# Create your models here.


Expand Down Expand Up @@ -60,16 +63,15 @@ class Status(models.TextChoices):
status = models.CharField(choices=Status, default=Status.NOT_STARTED, max_length=16)

@property
def latest_evaluation(self) -> Optional[Evaluation]:
def latest_evaluation(self) -> Evaluation | None:
"""
Return the latest Evaluation if it exists
"""
try:
return self.evaluations.latest('last_updated')
return self.evaluations.latest("last_updated")
except Evaluation.DoesNotExist:
return None


def __str__(self):
return f"({self.status}) {self.data_uri}"

Expand All @@ -93,7 +95,7 @@ class Status(models.TextChoices):
last_updated = models.DateTimeField(auto_now=True)

@property
def ordered_results(self) -> List:
def ordered_results(self) -> list:
"""
Return results of this evaluation, ordered per EVALUATION_DISPLAY_CONFIG
"""
Expand Down
52 changes: 24 additions & 28 deletions frx_challenges/web/templates/submission/detail.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends "page.html" %}
{% block head %}
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous"></script>
<link rel="stylesheet"
href="https://cdn.datatables.net/2.0.8/css/dataTables.dataTables.css" />
<script src="https://cdn.datatables.net/2.0.8/js/dataTables.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous"></script>
<link rel="stylesheet"
href="https://cdn.datatables.net/2.0.8/css/dataTables.dataTables.css" />
<script src="https://cdn.datatables.net/2.0.8/js/dataTables.js"></script>
{% endblock %}
{% block body %}
<div class="container py-2">
Expand All @@ -31,9 +31,7 @@ <h1>{{ submission.name }}</h1>
<th scope="col">Filename</th>
<th scope="col">Date uploaded</th>
<th scope="col">Evaluation Status</th>
{% for dc in evaluation_display_config %}
<th scope="col">{{ dc.display_name }}</th>
{% endfor %}
{% for dc in evaluation_display_config %}<th scope="col">{{ dc.display_name }}</th>{% endfor %}
</tr>
</thead>
<tbody>
Expand All @@ -44,29 +42,27 @@ <h1>{{ submission.name }}</h1>
<td>{{ v.date_created|date:"M j Y" }}</td>
<td>{{ v.latest_evaluation.status }}</td>
{% for r in v.latest_evaluation.ordered_results %}
<td scope="col">
{% if r %}
{{ r }}
{% endif %}
</td>
<td scope="col">
{% if r %}{{ r }}{% endif %}
</td>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="row py-2">
<div class="col">
<a href="{% url 'upload' submission.id %}" class="btn btn-primary mt-2">Upload submission</a>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
</div>
<script>
{% else %}
<div class="row py-2">
<div class="col">
<a href="{% url 'upload' submission.id %}" class="btn btn-primary mt-2">Upload submission</a>
</div>
</div>
{% endif %}
</div>
<script>
async function main() {
const resultsTable = new DataTable("#results");
}

main();
</script>
{% endblock body %}
</script>
{% endblock body %}
7 changes: 5 additions & 2 deletions frx_challenges/web/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.http import HttpRequest, HttpResponse, JsonResponse
from django.shortcuts import redirect, render
from django.db import transaction
from markdown_it import MarkdownIt
from mdit_py_plugins.footnote import footnote_plugin
from mdit_py_plugins.front_matter import front_matter_plugin
Expand Down Expand Up @@ -57,7 +57,10 @@ def upload(request: HttpRequest, id: int) -> HttpResponse:
def results(request: HttpRequest) -> HttpResponse:
evaluations = Evaluation.objects.all()

evaluations_resp = {"display_config": settings.EVALUATION_DISPLAY_CONFIG, "results": []}
evaluations_resp = {
"display_config": settings.EVALUATION_DISPLAY_CONFIG,
"results": [],
}

for ev in evaluations:
evaluations_resp["results"].append(
Expand Down

0 comments on commit bcc127a

Please sign in to comment.