Skip to content

Commit

Permalink
Merge pull request #37 from denvilk-bsuir/feature/TS-80-added-contest…
Browse files Browse the repository at this point in the history
…s-list

TS-80: Added view for contest list
DenVilk authored Dec 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 8297c36 + de81f5a commit 90d225d
Showing 10 changed files with 220 additions and 17 deletions.
Binary file modified source/web/locale/en_US/LC_MESSAGES/django.mo
Binary file not shown.
78 changes: 72 additions & 6 deletions source/web/locale/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-26 00:08+0300\n"
"POT-Creation-Date: 2024-12-14 01:53+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,11 +17,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: config/settings.py:128
#: config/settings.py:148
msgid "English"
msgstr "English"

#: config/settings.py:129
#: config/settings.py:149
msgid "Russian"
msgstr "Russian"

@@ -57,6 +57,44 @@ msgstr "Country"
msgid "EmailField"
msgstr "Email"

#: main/models.py:197
msgid "Opened"
msgstr "Opened contests"

#: main/models.py:198
msgid "Closed"
msgstr "Closed"

#: main/models.py:199
msgid "Ongoing"
msgstr "Ongoing"

#: templates/contests/contests_list.html:5
msgid "ContestsList"
msgstr "Contests"

#: templates/contests/contests_list.html:15 templates/tasks/tasks_list.html:15
msgid "ItemName"
msgstr "Name"

#: templates/contests/contests_list.html:16 templates/tasks/tasks_list.html:16
msgid "ItemType"
msgstr "Type"

#: templates/contests/contests_list.html:17
msgid "Status"
msgstr "Status"

#: templates/contests/contests_list.html:18
#: templates/contests/contests_list.html:29 templates/tasks/tasks_list.html:17
#: templates/tasks/tasks_list.html:27
msgid "Link"
msgstr "Link"

#: templates/contests/contests_list.html:33 templates/tasks/tasks_list.html:31
msgid "Empty"
msgstr "Empty"

#: templates/includes/header.html:4 templates/main/index.html:9
msgid "SysName"
msgstr "Test System"
@@ -65,16 +103,24 @@ msgstr "Test System"
msgid "HomePageName"
msgstr "Home"

#: templates/includes/header.html:23 templates/main/users/login.html:5
#: templates/includes/header.html:22
msgid "Contests"
msgstr "Contests"

#: templates/includes/header.html:25
msgid "Tasks"
msgstr "Tasks"

#: templates/includes/header.html:29 templates/main/users/login.html:5
#: templates/main/users/login.html:10
msgid "LoginPageName"
msgstr "Login"

#: templates/includes/header.html:26
#: templates/includes/header.html:32
msgid "SignupPageName"
msgstr "Sign Up"

#: templates/includes/header.html:32
#: templates/includes/header.html:38
msgid "LogoutButton"
msgstr "Logout"

@@ -102,5 +148,25 @@ msgstr "Sign Up"
msgid "SignUpButton"
msgstr "Sign up"

#: templates/tasks/tasks_list.html:5
msgid "TasksList"
msgstr "Tasks list"

#: templates/tasks/theta_code.html:11 templates/tasks/theta_quiz.html:11
msgid "TaskStatement"
msgstr "Statement"

#: templates/tasks/theta_code.html:13
msgid "TaskInputFormat"
msgstr "Input format"

#: templates/tasks/theta_code.html:15
msgid "TaskOutputFormat"
msgstr "Output format"

#: templates/tasks/theta_solutions.html:2
msgid "Submissions"
msgstr "Submissions"

#~ msgid "HelloWorld"
#~ msgstr "Hello World!"
Binary file modified source/web/locale/ru_RU/LC_MESSAGES/django.mo
Binary file not shown.
78 changes: 72 additions & 6 deletions source/web/locale/ru_RU/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-26 00:08+0300\n"
"POT-Creation-Date: 2024-12-14 01:53+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,11 +17,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: config/settings.py:128
#: config/settings.py:148
msgid "English"
msgstr "Английский"

#: config/settings.py:129
#: config/settings.py:149
msgid "Russian"
msgstr "Русский"

@@ -57,6 +57,44 @@ msgstr "Страна"
msgid "EmailField"
msgstr "Электронная почта"

#: main/models.py:197
msgid "Opened"
msgstr "Открыта регистрация"

#: main/models.py:198
msgid "Closed"
msgstr "Окончен"

#: main/models.py:199
msgid "Ongoing"
msgstr "Идет"

#: templates/contests/contests_list.html:5
msgid "ContestsList"
msgstr "Список контестов"

#: templates/contests/contests_list.html:15 templates/tasks/tasks_list.html:15
msgid "ItemName"
msgstr "Название"

#: templates/contests/contests_list.html:16 templates/tasks/tasks_list.html:16
msgid "ItemType"
msgstr "Тип"

#: templates/contests/contests_list.html:17
msgid "Status"
msgstr "Статус"

#: templates/contests/contests_list.html:18
#: templates/contests/contests_list.html:29 templates/tasks/tasks_list.html:17
#: templates/tasks/tasks_list.html:27
msgid "Link"
msgstr "Ссылка"

#: templates/contests/contests_list.html:33 templates/tasks/tasks_list.html:31
msgid "Empty"
msgstr "Пусто"

#: templates/includes/header.html:4 templates/main/index.html:9
msgid "SysName"
msgstr "Тестирующая Система"
@@ -65,16 +103,24 @@ msgstr "Тестирующая Система"
msgid "HomePageName"
msgstr "Главная"

#: templates/includes/header.html:23 templates/main/users/login.html:5
#: templates/includes/header.html:22
msgid "Contests"
msgstr "Контесты"

#: templates/includes/header.html:25
msgid "Tasks"
msgstr "Задачи"

#: templates/includes/header.html:29 templates/main/users/login.html:5
#: templates/main/users/login.html:10
msgid "LoginPageName"
msgstr "Авторизация"

#: templates/includes/header.html:26
#: templates/includes/header.html:32
msgid "SignupPageName"
msgstr "Регистрация"

#: templates/includes/header.html:32
#: templates/includes/header.html:38
msgid "LogoutButton"
msgstr "Выйти"

@@ -102,5 +148,25 @@ msgstr "Регистрация"
msgid "SignUpButton"
msgstr "Зарегистрироваться"

#: templates/tasks/tasks_list.html:5
msgid "TasksList"
msgstr "Список задач"

#: templates/tasks/theta_code.html:11 templates/tasks/theta_quiz.html:11
msgid "TaskStatement"
msgstr "Условие задачи"

#: templates/tasks/theta_code.html:13
msgid "TaskInputFormat"
msgstr "Формат ввода"

#: templates/tasks/theta_code.html:15
msgid "TaskOutputFormat"
msgstr "Формат вывода"

#: templates/tasks/theta_solutions.html:2
msgid "Submissions"
msgstr "Посылки"

#~ msgid "HelloWorld"
#~ msgstr "Привет Мир!"
16 changes: 16 additions & 0 deletions source/web/main/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from enum import Enum
from django.db import models
from django.db.models import F
from django.db.models.signals import post_save
from django.utils import timezone
from django.dispatch import receiver
from django.contrib.auth import get_user_model
from django.utils.translation import gettext_lazy as _


User = get_user_model()
@@ -191,6 +193,20 @@ class Contest(BaseModel):

objects = ContestManager()

class ContestStatus(Enum):
OPENED = ('opened', _('Opened'))
CLOSED = ('closed', _('Closed'))
ONGOING = ('ongoing', _('Ongoing'))

@property
def status(self):
now = timezone.now()
if now < self.start_time:
return self.ContestStatus.OPENED
if self.start_time <= now < self.start_time + self.duration:
return self.ContestStatus.ONGOING
return self.ContestStatus.CLOSED

def __str__(self):
return f"#{self.id} {self.name}"

2 changes: 2 additions & 0 deletions source/web/main/urls.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
TaskView,
TaskListView,
UserLoginView,
ContestListView,
ContestDetailView,
ContestTaskView,
)
@@ -25,6 +26,7 @@
path('tasks/<int:id>/theta_code', code_answer, name='theta_code'),
path('tasks/<int:id>/theta_quiz', quiz_answer, name='theta_quiz'),

path('contest/', ContestListView.as_view(), name='contests'),
path('contest/<int:id>/', ContestDetailView.as_view(), name='contest_detail'),
path('contest/<int:id>/<int:task_order>', ContestTaskView.as_view(), name='contest_detail_task'),
path('contest/<int:id>/register', ContestRegisterView.as_view(), name='contest_register'),
8 changes: 8 additions & 0 deletions source/web/main/views.py
Original file line number Diff line number Diff line change
@@ -110,6 +110,14 @@ def get(self, request, *args, **kwargs):
return render(request, self.template_name, {'tasks': tasks})


class ContestListView(TemplateView):
template_name = 'contests/contests_list.html'

def get(self, request, *args, **kwargs):
contests = Contest.objects.all().order_by('-start_time')
return render(request, self.template_name, {'contests': contests})


class ContestRegisterView(TemplateView):
template_name = 'contests/registration.html'

39 changes: 39 additions & 0 deletions source/web/templates/contests/contests_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends "wrapper.html" %}
{% load i18n %}

{% block title %}
{% trans "ContestsList" %}
{% endblock %}

{% block content %}
<div class="container">
<div class="row">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>{% trans "ItemName" %}</th>
<th>{% trans "ItemType" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Link" %}</th>
</tr>
</thead>
<tbody>
{% if contests %}
{% for contest in contests %}
<tr>
<td>{{contest.pk}}</td>
<td>{{contest.name}}</td>
<td>{{contest.type.name}}</td>
<td>{{contest.status.value.1}}</td>
<td><a href="{% url 'contest_detail' contest.pk %}">{% trans 'Link' %}</a></td>
</tr>
{% endfor %}
{% else %}
{% trans "Empty" %}
{% endif %}
</tbody>
</table>
</div>
</div>
{% endblock %}
6 changes: 6 additions & 0 deletions source/web/templates/includes/header.html
Original file line number Diff line number Diff line change
@@ -18,6 +18,12 @@
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{% url 'index' %}">{% trans 'HomePageName' %}</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{% url 'contests' %}">{% trans 'Contests' %}</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{% url 'tasks' %}">{% trans 'Tasks' %}</a>
</li>
{% if not request.user.is_authenticated %}
<li class="nav-item">
<a class="nav-link active" href="{% url 'login' %}">{% trans "LoginPageName" %}</a>
10 changes: 5 additions & 5 deletions source/web/templates/tasks/tasks_list.html
Original file line number Diff line number Diff line change
@@ -12,9 +12,9 @@
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Type</th>
<th>Link</th>
<th>{% trans "ItemName" %}</th>
<th>{% trans "ItemType" %}</th>
<th>{% trans "Link" %}</th>
</tr>
</thead>
<tbody>
@@ -24,11 +24,11 @@
<td>{{task.pk}}</td>
<td>{{task.name}}</td>
<td>{{task.task_type.name}}</td>
<td><a href="{% url 'theta_task' task.pk %}">Link</a></td>
<td><a href="{% url 'theta_task' task.pk %}">{% trans "Link" %}</a></td>
</tr>
{% endfor %}
{% else %}
No tasks.
{% trans "Empty" %}
{% endif %}
</tbody>
</table>

0 comments on commit 90d225d

Please sign in to comment.