From 42b9681cbd56bc8934754705b9cf3e584237040f Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Tue, 30 Jun 2026 13:20:32 +0200 Subject: [PATCH 01/13] feat: more difficulties --- school/courses/templates/courses/lesson.html | 28 +----------------- school/problems/models.py | 10 ++++--- .../problems/_problem_statement.html | 27 +++++++++++++++++ .../templates/problems/problem_detail.html | 29 +------------------ 4 files changed, 35 insertions(+), 59 deletions(-) create mode 100644 school/problems/templates/problems/_problem_statement.html diff --git a/school/courses/templates/courses/lesson.html b/school/courses/templates/courses/lesson.html index 2e9b12b..2c4a854 100644 --- a/school/courses/templates/courses/lesson.html +++ b/school/courses/templates/courses/lesson.html @@ -72,33 +72,7 @@ {% endif %} {% elif item.problem %} -
- Tagy: - {% for tag in item.problem.tags.all %} - - {{ tag }} - - {% endfor %} -
-
- {% if item.problem.difficulty == item.problem.ProblemDifficulty.EASY %} - Obtiažnosť: - - easy - - {% elif item.problem.difficulty == item.problem.ProblemDifficulty.MEDIUM %} - Obtiažnosť: - - medium - - {% elif item.problem.difficulty == item.problem.ProblemDifficulty.HARD %} - Obtiažnosť: - - hard - - {% endif %} -
- {{ item.problem.content|markdownify }} + {% include "problems/_problem_statement.html" with problem=item.problem %} {% endif %} diff --git a/school/problems/models.py b/school/problems/models.py index e279910..489aad1 100644 --- a/school/problems/models.py +++ b/school/problems/models.py @@ -30,10 +30,12 @@ def __str__(self): class Problem(models.Model): class ProblemDifficulty(models.TextChoices): - EASY = "easy", "easy" - MEDIUM = "medium", "medium" - HARD = "hard", "hard" - UNKNOWN = "unknown", "unknown" + BASICS = "basics", "základy" + EASY = "easy", "ľahká" + MEDIUM = "medium", "stredná" + HARD = "hard", "ťažká" + VERY_HARD = "very-hard", "veľmi ťažká" + UNKNOWN = "unknown", "neznáma" id: int diff --git a/school/problems/templates/problems/_problem_statement.html b/school/problems/templates/problems/_problem_statement.html new file mode 100644 index 0000000..21167bc --- /dev/null +++ b/school/problems/templates/problems/_problem_statement.html @@ -0,0 +1,27 @@ +{% load markdownify %} + +
+ Tagy: + {% for tag in problem.tags.all %} + + {{ tag }} + + {% endfor %} +
+
+ Obtiažnosť: + {% if problem.difficulty == problem.ProblemDifficulty.EASY %} + + easy + + {% elif problem.difficulty == problem.ProblemDifficulty.MEDIUM %} + + medium + + {% elif problem.difficulty == problem.ProblemDifficulty.HARD %} + + hard + + {% endif %} +
+{{ problem.content|markdownify }} diff --git a/school/problems/templates/problems/problem_detail.html b/school/problems/templates/problems/problem_detail.html index f1d152a..c138191 100644 --- a/school/problems/templates/problems/problem_detail.html +++ b/school/problems/templates/problems/problem_detail.html @@ -1,7 +1,6 @@ {% extends 'common/base.html' %} {% load percent %} {% load submits %} -{% load markdownify %} {% block title %}{{ problem.name }} {{ block.super }}{% endblock %} @@ -11,33 +10,7 @@
-
- Tagy: - {% for tag in problem.tags.all %} - - {{ tag }} - - {% endfor %} -
-
- {% if problem.difficulty == problem.ProblemDifficulty.EASY %} - Obtiažnosť: - - easy - - {% elif problem.difficulty == problem.ProblemDifficulty.MEDIUM %} - Obtiažnosť: - - medium - - {% elif problem.difficulty == problem.ProblemDifficulty.HARD %} - Obtiažnosť: - - hard - - {% endif %} -
- {{ problem.content|markdownify }} + {% include "problems/_problem_statement.html" with problem=problem %}
{% endif %} {% elif item.problem %} - {% include "problems/_problem_statement.html" with problem=item.problem %} + {% include "problems/_partials/problem_statement.html" with problem=item.problem %} {% endif %} diff --git a/school/problems/templates/problems/_partials/problem_statement.html b/school/problems/templates/problems/_partials/problem_statement.html new file mode 100644 index 0000000..60eea4d --- /dev/null +++ b/school/problems/templates/problems/_partials/problem_statement.html @@ -0,0 +1,13 @@ +{% load markdownify tags %} + +
+ Tagy: + {% for tag in problem.tags.all %} + {% render_tag tag %} + {% endfor %} +
+
+ Obtiažnosť: + {% render_tag problem.difficulty is_difficulty=True %} +
+{{ problem.content|markdownify }} diff --git a/school/problems/templates/problems/_partials/tag.html b/school/problems/templates/problems/_partials/tag.html new file mode 100644 index 0000000..6d8cb8b --- /dev/null +++ b/school/problems/templates/problems/_partials/tag.html @@ -0,0 +1,7 @@ + + {{ tag }} + diff --git a/school/problems/templates/problems/_problem_statement.html b/school/problems/templates/problems/_problem_statement.html deleted file mode 100644 index 21167bc..0000000 --- a/school/problems/templates/problems/_problem_statement.html +++ /dev/null @@ -1,27 +0,0 @@ -{% load markdownify %} - -
- Tagy: - {% for tag in problem.tags.all %} - - {{ tag }} - - {% endfor %} -
-
- Obtiažnosť: - {% if problem.difficulty == problem.ProblemDifficulty.EASY %} - - easy - - {% elif problem.difficulty == problem.ProblemDifficulty.MEDIUM %} - - medium - - {% elif problem.difficulty == problem.ProblemDifficulty.HARD %} - - hard - - {% endif %} -
-{{ problem.content|markdownify }} diff --git a/school/problems/templates/problems/problem_detail.html b/school/problems/templates/problems/problem_detail.html index c138191..622f090 100644 --- a/school/problems/templates/problems/problem_detail.html +++ b/school/problems/templates/problems/problem_detail.html @@ -10,7 +10,7 @@
- {% include "problems/_problem_statement.html" with problem=problem %} + {% include "problems/_partials/problem_statement.html" with problem=problem %}
diff --git a/school/problems/templates/problems/problem_list.html b/school/problems/templates/problems/problem_list.html index c8a4b81..fa8ddda 100644 --- a/school/problems/templates/problems/problem_list.html +++ b/school/problems/templates/problems/problem_list.html @@ -5,13 +5,13 @@ {% block body %}
-
+

Zoznam úloh

Na tejto stránke sa nachádza zoznam všetkých úloh. Ak ešte nemáš absolvované aspoň základné kurzy, - silno ti odporúčame si prejsť najskôr tie. + silno ti odporúčame prejsť si najskôr tie.

diff --git a/tailwind.config.js b/tailwind.config.js index 39aad77..909a7ba 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -8,9 +8,19 @@ module.exports = { sans: ['Inter', ...defaultTheme.fontFamily.sans], mono: ['"Fira Mono"', ...defaultTheme.fontFamily.mono], }, + colors: { + 'ksp': '#818f3d', + 'ksp-dark': '#41481f', + 'ksp-semi-dark': '#565f29', + 'ksp-light': '#abb47e', + 'ksp-semi-light': '#9aa564', + }, typography: { DEFAULT: { css: { + 'a': { + color: '#818f3d', + }, 'code::before': { content: '', }, From 5f6747966c150ad16f8831fcbddf7a5cc7d329f8 Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Thu, 2 Jul 2026 19:08:40 +0200 Subject: [PATCH 07/13] feat: make import atomic --- school/imports/views/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/school/imports/views/__init__.py b/school/imports/views/__init__.py index 3f8afc9..52ba68b 100644 --- a/school/imports/views/__init__.py +++ b/school/imports/views/__init__.py @@ -4,6 +4,7 @@ import frontmatter from django.conf import settings +from django.db import transaction from django.http import HttpRequest, JsonResponse from django.utils.decorators import method_decorator from django.views import View @@ -15,6 +16,7 @@ @method_decorator(csrf_exempt, name="dispatch") class ImportView(View): + @transaction.atomic() def dispatch(self, request: HttpRequest, *args, **kwargs): token = request.headers.get("X-Token", None) if token != settings.SCHOOL_IMPORT_TOKEN: From 5bd4eb5d06dabefe09c7e34a135cf869d450d5a8 Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Thu, 2 Jul 2026 19:08:47 +0200 Subject: [PATCH 08/13] fix: error message --- school/imports/views/courses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/school/imports/views/courses.py b/school/imports/views/courses.py index 09f0de4..8863d4f 100644 --- a/school/imports/views/courses.py +++ b/school/imports/views/courses.py @@ -91,7 +91,7 @@ def post(self, request, *args, **kwargs): if problem is None: return JsonResponse( { - "errors": f"Problem '{item['material']}' don't exist.'", + "errors": f"Problem '{item['problem']}' don't exist.'", "ok": False, }, status=400, From b54d86b1f182a27397c6f3b0e8961ce8fcb83e50 Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Thu, 2 Jul 2026 21:26:46 +0200 Subject: [PATCH 09/13] fix: remove unused styles --- tailwind.config.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tailwind.config.js b/tailwind.config.js index 909a7ba..3bc83a3 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -10,17 +10,11 @@ module.exports = { }, colors: { 'ksp': '#818f3d', - 'ksp-dark': '#41481f', - 'ksp-semi-dark': '#565f29', - 'ksp-light': '#abb47e', 'ksp-semi-light': '#9aa564', }, typography: { DEFAULT: { css: { - 'a': { - color: '#818f3d', - }, 'code::before': { content: '', }, From 460a406a92b853ef72e56557c0ab7055440ec3b5 Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Thu, 2 Jul 2026 21:30:05 +0200 Subject: [PATCH 10/13] fix: better styles --- school/problems/templates/problems/_partials/tag.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/school/problems/templates/problems/_partials/tag.html b/school/problems/templates/problems/_partials/tag.html index ad7d27f..cd913ac 100644 --- a/school/problems/templates/problems/_partials/tag.html +++ b/school/problems/templates/problems/_partials/tag.html @@ -4,7 +4,7 @@ {% else %} {{ tag }} From 76a2191975eb047c56b2ac0d4d175d0bc353bf21 Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Thu, 2 Jul 2026 21:35:28 +0200 Subject: [PATCH 11/13] fix: do not include `None` tag if problem with no tag exists --- school/problems/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/school/problems/views.py b/school/problems/views.py index 574b953..4044681 100644 --- a/school/problems/views.py +++ b/school/problems/views.py @@ -76,7 +76,8 @@ def get_queryset(self): @cached_property def tags(self): return ( - Problem.objects.values_list("tags__name", flat=True) + Problem.objects.exclude(tags__name__isnull=True) + .values_list("tags__name", flat=True) .order_by("tags__name") .distinct() ) From 195b03fdbc8933e4c3e0970efd54db1f217129b0 Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Fri, 3 Jul 2026 12:14:30 +0200 Subject: [PATCH 12/13] feat: hide tags list when empty --- .../problems/_partials/problem_statement.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/school/problems/templates/problems/_partials/problem_statement.html b/school/problems/templates/problems/_partials/problem_statement.html index 1aed037..ce49e33 100644 --- a/school/problems/templates/problems/_partials/problem_statement.html +++ b/school/problems/templates/problems/_partials/problem_statement.html @@ -1,11 +1,13 @@ {% load markdownify tags %} -
- Tagy: - {% for tag in problem.tags.all %} - {% render_tag tag %} - {% endfor %} -
+{% if problem.tags.all %} +
+ Tagy: + {% for tag in problem.tags.all %} + {% render_tag tag %} + {% endfor %} +
+{% endif %}
Obtiažnosť: {% render_tag problem.difficulty_tag %} From 74becd434e5689eed82972c821349af6db99b2f9 Mon Sep 17 00:00:00 2001 From: Aiq0 <66842415+Aiq0@users.noreply.github.com> Date: Fri, 3 Jul 2026 15:40:39 +0200 Subject: [PATCH 13/13] fix: disable build scripts --- pnpm-workspace.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 12d9ab2..6307130 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,4 +1,4 @@ allowBuilds: - '@parcel/watcher': set this to true or false - core-js: set this to true or false - esbuild: set this to true or false + '@parcel/watcher': false + core-js: false + esbuild: false