From 08b44f9410b7dd9e6d082b9622c425ee11e6bef3 Mon Sep 17 00:00:00 2001 From: LuizaMaluf Date: Tue, 28 Nov 2023 10:47:00 -0300 Subject: [PATCH 01/52] feat(submission_page): arquivos --- apps/submissions/urls.py | 0 apps/submissions/views.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/submissions/urls.py create mode 100644 apps/submissions/views.py diff --git a/apps/submissions/urls.py b/apps/submissions/urls.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/submissions/views.py b/apps/submissions/views.py new file mode 100644 index 0000000..e69de29 From a47836db06d3c0c93aefce2397978c2c0d0d1a91 Mon Sep 17 00:00:00 2001 From: LuizaMaluf Date: Wed, 29 Nov 2023 08:46:56 -0300 Subject: [PATCH 02/52] feat(submission_page): submissions list --- apps/submissions/urls.py | 7 ++++++ apps/submissions/views.py | 9 +++++++ templates/submission/submission_list.html | 30 +++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 templates/submission/submission_list.html diff --git a/apps/submissions/urls.py b/apps/submissions/urls.py index e69de29..5070325 100644 --- a/apps/submissions/urls.py +++ b/apps/submissions/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from apps.submissions.views import SubmissionListView + +urlpatterns = [ + path("submissions/", SubmissionListView.as_view(), name="submission_list") +] diff --git a/apps/submissions/views.py b/apps/submissions/views.py index e69de29..964f1f2 100644 --- a/apps/submissions/views.py +++ b/apps/submissions/views.py @@ -0,0 +1,9 @@ +from django.views.generic import ListView + +from apps.submissions.models import Submission + + +class SubmissionListView(ListView[Submission]): + model = Submission + template_name = "submission_list.html" + context_object_name = "submissions" diff --git a/templates/submission/submission_list.html b/templates/submission/submission_list.html new file mode 100644 index 0000000..67dcb99 --- /dev/null +++ b/templates/submission/submission_list.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} + +{% block title %}Lista de Submissões{% endblock title %} + +{% block content %} +
+

Lista de Submissões

+ +
+ {% for submission in submissions %} +
+
+ + Submissão #{{ submission.id }} + + + Autor: {{ submission.author.username }} + + + Status: {{ submission.get_status_display }} + +
+
+

Tarefa: {{ submission.task.title }}

+
+
+ {% endfor %} +
+
+{% endblock content %} From bee9204d49f365afef2c13b627726a00b6b5a95d Mon Sep 17 00:00:00 2001 From: LuizaMaluf Date: Wed, 29 Nov 2023 10:23:16 -0300 Subject: [PATCH 03/52] feat(submission_page): submissions list tests --- apps/submissions/tests.py | 41 ++++++++++++++++++++++ apps/submissions/views.py | 9 ++++- server/urls.py | 1 + templates/submission/submission_list.html | 30 ---------------- templates/submissions/submission_list.html | 0 5 files changed, 50 insertions(+), 31 deletions(-) delete mode 100644 templates/submission/submission_list.html create mode 100644 templates/submissions/submission_list.html diff --git a/apps/submissions/tests.py b/apps/submissions/tests.py index fe42958..9fedc94 100644 --- a/apps/submissions/tests.py +++ b/apps/submissions/tests.py @@ -3,6 +3,7 @@ from django.contrib.admin.sites import AdminSite from django.core.exceptions import ValidationError from django.test import TestCase +from django.urls import reverse from django.utils import timezone from django.utils.translation import gettext as _ @@ -94,3 +95,43 @@ def test_fieldsets(self) -> None: (_("Details"), {"fields": ("author", "task", "code", "status")}) ] self.assertEqual(self.submission_admin.fieldsets, expected) + + +class SubmissionListView(TestCase): + def setUp(self) -> None: + self.user = User.objects.create_user( + username="testuser", + email="testuser@example", + password="testpassword", + ) + + self.contest = Contest._default_manager.create( + title="Test Contest", + description="This is a test contest", + start_time=timezone.now(), + end_time=timezone.now() + timedelta(hours=1), + cancelled=False, + ) + + self.task = Task._default_manager.create( + title="Test Task", + description="This is a test task", + contest=self.contest, + ) + + self.submission = Submission._default_manager.create( + author=self.user, + task=self.task, + code="test code", + ) + + def test_submission_list_view(self) -> None: + self.client.login(email="testuser@example", password="testpassword") + + url = reverse("submission_list") + + response = self.client.get(url) + + self.assertEqual(response.status_code, 200) + self.assertTrue("submissions" in response.context) + self.assertIn(self.submission, response.context["submissions"]) diff --git a/apps/submissions/views.py b/apps/submissions/views.py index 964f1f2..e715b2d 100644 --- a/apps/submissions/views.py +++ b/apps/submissions/views.py @@ -1,9 +1,16 @@ +from typing import TYPE_CHECKING + from django.views.generic import ListView from apps.submissions.models import Submission +if TYPE_CHECKING: + SubmissionViewBase = ListView[Submission] +else: + SubmissionViewBase = ListView + -class SubmissionListView(ListView[Submission]): +class SubmissionListView(SubmissionViewBase): model = Submission template_name = "submission_list.html" context_object_name = "submissions" diff --git a/server/urls.py b/server/urls.py index c9f993e..2570b89 100644 --- a/server/urls.py +++ b/server/urls.py @@ -12,4 +12,5 @@ path("contests/", include("apps.contests.urls"), name="contests"), path("tasks/", include("apps.tasks.urls")), path("", include("apps.users.urls")), + path("submissions/", include("apps.submissions.urls")), ] diff --git a/templates/submission/submission_list.html b/templates/submission/submission_list.html deleted file mode 100644 index 67dcb99..0000000 --- a/templates/submission/submission_list.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Lista de Submissões{% endblock title %} - -{% block content %} -
-

Lista de Submissões

- -
- {% for submission in submissions %} -
-
- - Submissão #{{ submission.id }} - - - Autor: {{ submission.author.username }} - - - Status: {{ submission.get_status_display }} - -
-
-

Tarefa: {{ submission.task.title }}

-
-
- {% endfor %} -
-
-{% endblock content %} diff --git a/templates/submissions/submission_list.html b/templates/submissions/submission_list.html new file mode 100644 index 0000000..e69de29 From 11103bb4960eead358fd4fff126854164997be7a Mon Sep 17 00:00:00 2001 From: LuizaMaluf Date: Wed, 29 Nov 2023 10:27:57 -0300 Subject: [PATCH 04/52] feat(submission_page): submissions list tests --- templates/base.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/base.html b/templates/base.html index ebbd635..0e159cb 100644 --- a/templates/base.html +++ b/templates/base.html @@ -69,6 +69,7 @@ Ranking + Submissions {% if request.user.is_authenticated %} From 48d650dfee8272e24fda0b367b3c68a4738d5c5a Mon Sep 17 00:00:00 2001 From: LuizaMaluf Date: Wed, 29 Nov 2023 11:20:32 -0300 Subject: [PATCH 05/52] feat(submission_page): template of submissions incomplete --- apps/submissions/tests.py | 2 +- apps/submissions/urls.py | 6 +++--- templates/submissions/submission_list.html | 23 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/apps/submissions/tests.py b/apps/submissions/tests.py index 9fedc94..85703b3 100644 --- a/apps/submissions/tests.py +++ b/apps/submissions/tests.py @@ -128,7 +128,7 @@ def setUp(self) -> None: def test_submission_list_view(self) -> None: self.client.login(email="testuser@example", password="testpassword") - url = reverse("submission_list") + url = reverse("submissions:list") response = self.client.get(url) diff --git a/apps/submissions/urls.py b/apps/submissions/urls.py index 5070325..6ee5e84 100644 --- a/apps/submissions/urls.py +++ b/apps/submissions/urls.py @@ -2,6 +2,6 @@ from apps.submissions.views import SubmissionListView -urlpatterns = [ - path("submissions/", SubmissionListView.as_view(), name="submission_list") -] +app_name = "submissions" + +urlpatterns = [path("", SubmissionListView.as_view(), name="list")] diff --git a/templates/submissions/submission_list.html b/templates/submissions/submission_list.html index e69de29..af9d08d 100644 --- a/templates/submissions/submission_list.html +++ b/templates/submissions/submission_list.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} + +{% load crispy_forms_tags %} + +{% block title %}Submissions{% endblock title %} + +{% block content %} + +

Submissions

+
    + {% for submission in submissions %} +
  • + Submission ID: {{ submission.id }} - + + - {{ task.title }} + + - Status: {{ submission.status }} + - Data: {{ submission.created_at }} +
  • + {% endfor %} +
+ +{% endblock content %} From 297cd3cc9fb0a7fe24a9b58bbcb32b9845d18de5 Mon Sep 17 00:00:00 2001 From: LuizaMaluf Date: Thu, 30 Nov 2023 20:45:15 -0300 Subject: [PATCH 06/52] feat(submission_page): template of submissions complete --- apps/submissions/views.py | 2 +- templates/base.html | 1 - templates/submissions/list.html | 57 ++++++++++++++++++++++ templates/submissions/submission_list.html | 23 --------- 4 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 templates/submissions/list.html delete mode 100644 templates/submissions/submission_list.html diff --git a/apps/submissions/views.py b/apps/submissions/views.py index e715b2d..6a2dc04 100644 --- a/apps/submissions/views.py +++ b/apps/submissions/views.py @@ -12,5 +12,5 @@ class SubmissionListView(SubmissionViewBase): model = Submission - template_name = "submission_list.html" + template_name = "submissions/list.html" context_object_name = "submissions" diff --git a/templates/base.html b/templates/base.html index 0e159cb..ebbd635 100644 --- a/templates/base.html +++ b/templates/base.html @@ -69,7 +69,6 @@ Ranking - Submissions {% if request.user.is_authenticated %} diff --git a/templates/submissions/list.html b/templates/submissions/list.html new file mode 100644 index 0000000..bd5869a --- /dev/null +++ b/templates/submissions/list.html @@ -0,0 +1,57 @@ +{% extends "base.html" %} + +{% load crispy_forms_tags %} + +{% block title %}Submissions{% endblock title %} + +{% block content %} +

Submissions

+ + + + + + + +
+ + + + + + + + + + + {% for submission in submissions.all %} + + + + + + + {% endfor %} + +
Submission IDTaskStatusCreated at
{{ submission.id }}{{ submission.task.title }}{{ submission.status }}{{ submission.created_at}}
+
+ +{% endblock content %} diff --git a/templates/submissions/submission_list.html b/templates/submissions/submission_list.html deleted file mode 100644 index af9d08d..0000000 --- a/templates/submissions/submission_list.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "base.html" %} - -{% load crispy_forms_tags %} - -{% block title %}Submissions{% endblock title %} - -{% block content %} - -

Submissions

-
    - {% for submission in submissions %} -
  • - Submission ID: {{ submission.id }} - - - - {{ task.title }} - - - Status: {{ submission.status }} - - Data: {{ submission.created_at }} -
  • - {% endfor %} -
- -{% endblock content %} From b2c54246349202e0f317cc8c30ee46c11faba09e Mon Sep 17 00:00:00 2001 From: LuizaMaluf Date: Thu, 30 Nov 2023 20:48:23 -0300 Subject: [PATCH 07/52] feat(submission_page): add submissions to nav bar --- templates/base.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/base.html b/templates/base.html index ebbd635..8d0e4de 100644 --- a/templates/base.html +++ b/templates/base.html @@ -70,6 +70,11 @@ Ranking + {% if request.user.is_authenticated %}