This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from unb-mds/feature/submission-page
[feature request] Criar página de submissões
- Loading branch information
Showing
8 changed files
with
189 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import path | ||
|
||
from apps.submissions.views import SubmissionListView | ||
|
||
app_name = "submissions" | ||
|
||
urlpatterns = [path("", SubmissionListView.as_view(), name="list")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from django.db.models import QuerySet | ||
from django.views.generic import ListView | ||
|
||
from apps.submissions.models import Submission | ||
|
||
if TYPE_CHECKING: | ||
SubmissionViewBase = ListView[Submission] | ||
else: | ||
SubmissionViewBase = ListView | ||
|
||
|
||
class SubmissionListView(SubmissionViewBase): | ||
model = Submission | ||
template_name = "submissions/list.html" | ||
context_object_name = "submissions" | ||
paginate_by = 10 | ||
|
||
def get_queryset(self) -> QuerySet[Submission]: | ||
return Submission._default_manager.all().order_by("-created_at") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ | |
} | ||
</style> | ||
|
||
{% block head %}{% endblock head %} | ||
|
||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" | ||
|
@@ -70,6 +72,11 @@ | |
Ranking | ||
</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link text-white" href="{% url 'submissions:list' %}"> | ||
Submissions | ||
</a> | ||
</li> | ||
</ul> | ||
{% if request.user.is_authenticated %} | ||
<div class="dropdown"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{% extends "base.html" %} | ||
|
||
{% load crispy_forms_tags %} | ||
|
||
{% block title %}Submissions{% endblock title %} | ||
|
||
{% block head %} | ||
<style> | ||
.center-table { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
margin: 20px 0; | ||
} | ||
th, td { | ||
border: 1px solid #dddddd; | ||
text-align: left; | ||
padding: 8px; | ||
text-align: center; | ||
} | ||
th { | ||
background-color: #f2f2f2; | ||
} | ||
</style> | ||
{% endblock head %} | ||
|
||
{% block content %} | ||
<h2>Submissions</h2> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Submission ID</th> | ||
<th>User</th> | ||
<th>Task</th> | ||
<th>Status</th> | ||
<th>Created at</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for submission in page_obj %} | ||
<tr> | ||
<td>{{ submission.id }}</td> | ||
<td> | ||
<a href="{% url 'users:profile' submission.author.username %}"> | ||
{{ submission.author.username }} | ||
</a> | ||
</td> | ||
<td> | ||
<a href="{% url 'tasks:detail' submission.task.id %}"> | ||
{{ submission.task.title }} | ||
</a> | ||
</td> | ||
<td>{{ submission.status }}</td> | ||
<td>{{ submission.created_at }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
<nav aria-label="Page navigation example"> | ||
<ul class="pagination"> | ||
{% if page_obj.has_previous %} | ||
<li class="page-item"> | ||
<a class="page-link" href="?page=1" tabindex="-1">First</a> | ||
</li> | ||
<li class="page-item"> | ||
<a class="page-link" href="?page={{ page_obj.previous_page_number }}">Previous</a> | ||
</li> | ||
{% else %} | ||
<li class="page-item disabled"> | ||
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a> | ||
</li> | ||
{% endif %} | ||
|
||
{% for i in page_obj.paginator.page_range %} | ||
{% if page_obj.number == i %} | ||
<li class="page-item active"> | ||
<a class="page-link" href="?page={{ i }}">{{ i }} </a> | ||
</li> | ||
{% else %} | ||
<li class="page-item"> | ||
<a class="page-link" href="?page={{ i }}">{{ i }}</a> | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if page_obj.has_next %} | ||
<li class="page-item"> | ||
<a class="page-link" href="?page={{ page_obj.next_page_number }}">Next</a> | ||
</li> | ||
<li class="page-item"> | ||
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}">Last</a> | ||
</li> | ||
{% else %} | ||
<li class="page-item disabled"> | ||
<a class="page-link" href="#" aria-disabled="true">Next</a> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
</nav> | ||
{% endblock content %} |