Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

[documentation] Criar documentação da ata 03 #40

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c32e77
Merge pull request #13 from unb-mds/feature/django-bootstrap
bitterteriyaki Sep 22, 2023
8ad63cf
feat(templates): add the initial project templates
bitterteriyaki Sep 26, 2023
bd5909a
feat(templates/base): add the initial navbar
bitterteriyaki Sep 26, 2023
a577c09
feat(templates): add initial registering template
LuizaMaluf Sep 28, 2023
5bb1483
style: fix code code style
bitterteriyaki Sep 28, 2023
8725e46
chore(pyproject): change project name
bitterteriyaki Sep 30, 2023
41be42f
feat(apps/users): add the initial users app
bitterteriyaki Sep 30, 2023
566e487
fix: fix `mypy` module conflict
bitterteriyaki Sep 30, 2023
677f34e
Merge pull request #17 from unb-mds/feature/user-model
bitterteriyaki Sep 30, 2023
d060337
feat(apps/contests): add the initial contests app
bitterteriyaki Sep 30, 2023
443a5e3
feat(apps/contests): add a status field to the contest model
bitterteriyaki Sep 30, 2023
dcea9ca
feat(apps/contests): add the initial views for the contest app
bitterteriyaki Sep 30, 2023
dd58307
feat(apps/contests): save the sent code as a string buffer
bitterteriyaki Sep 30, 2023
47e9402
feat(apps/contests): improve the admin page
bitterteriyaki Oct 1, 2023
a8facb4
build(deps-dev): bump urllib3 from 2.0.5 to 2.0.6
dependabot[bot] Oct 3, 2023
c57512f
Merge pull request #20 from unb-mds/dependabot/pip/urllib3-2.0.6
bitterteriyaki Oct 3, 2023
819783c
Merge branch 'main' into feature/contests
bitterteriyaki Oct 3, 2023
a539ed7
Merge pull request #18 from unb-mds/feature/contests
bitterteriyaki Oct 3, 2023
f0bef79
docs: add second meeting minutes
thegm445 Oct 4, 2023
9860629
Merge pull request #22 from unb-mds/documentation/ata-02
bitterteriyaki Oct 4, 2023
ecb4c0e
feat(apps/problems): add the initial problem app
bitterteriyaki Oct 4, 2023
67ac74d
feat(templates/contests): add the contest duration inside the card
bitterteriyaki Oct 4, 2023
e297346
feat(templates/contests): improve contests list page
bitterteriyaki Oct 4, 2023
cb12cac
feat(templates/contests): show the number of problems in a contest
bitterteriyaki Oct 4, 2023
6b27a6c
feat(templates/contests): improve the contest details page
bitterteriyaki Oct 5, 2023
cdd8cb6
fix(templates/contests): pluralize the word `problem` correctly
bitterteriyaki Oct 5, 2023
3ff43e8
Merge pull request #26 from unb-mds/feature/problems
bitterteriyaki Oct 5, 2023
b4948cd
docs(sprints): add initial sprints documentation
thegm445 Oct 6, 2023
fccd6e8
docs(sprints): fix minor issues
thegm445 Oct 6, 2023
ee6079d
docs(installation): add instructions on README
thegm445 Oct 10, 2023
42b75d3
docs(installation): add instructions on README
thegm445 Oct 10, 2023
dbaf5c4
docs: add third meeting minutes
thegm445 Oct 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este código pertence a outro pull request.

Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# 2023-2-Squad06

# Guia de instalação

## Resumo

Para a instalação e a operação corretas, deve se ter instalado na máquina:
- Python versão 3.11.5
- Poetry versão 1.6.1

Após verificar quanto aos requisitos acima, rode estes comandos:

- `poetry install`
- Se necessárias dependências de documentação, `poetry install --with docs`
- Para instalar Git Hooks:
```bash
poetry run pre-commit install \
--hook-type commit-msg \
--hook-type pre-commit \
--hook-type pre-push
```
- Gerar o arquivo config `poetry run ./bin/create-env`
- Para finalizar a instalação e conseguir visualizar a página:

- `docker compose build && docker compose up -d`
- `docker compose run django python manage.py migrate`
- `docker compose run django python manage.py createsuperuser`
File renamed without changes.
8 changes: 8 additions & 0 deletions apps/contests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig

default_app_config = "apps.contests.ContestsConfig"


class ContestsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.contests"
35 changes: 35 additions & 0 deletions apps/contests/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import TYPE_CHECKING

from django.contrib.admin import ModelAdmin, register
from django.forms import CharField, ModelForm, Textarea
from django.utils.translation import gettext_lazy as _

from apps.contests.models import Contest

if TYPE_CHECKING:
ContestAdminBase = ModelAdmin[Contest]
ContestModelFormBase = ModelForm[Contest]
else:
ContestAdminBase = ModelAdmin
ContestModelFormBase = ModelForm


class ContestModelForm(ContestModelFormBase):
description = CharField(widget=Textarea(attrs={"rows": 14, "cols": 80}))

class Meta:
model = Contest
fields = "__all__"


@register(Contest)
class ContestAdmin(ContestAdminBase):
form = ContestModelForm

list_display = ("title", "start_time", "end_time", "status")
list_filter = ("start_time", "end_time")

fieldsets = [
(_("General"), {"fields": ("title", "description")}),
(_("Other"), {"fields": ("start_time", "end_time", "cancelled")}),
]
8 changes: 8 additions & 0 deletions apps/contests/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from enum import StrEnum


class ContestStatus(StrEnum):
PENDING = "Pending"
RUNNING = "Running"
FINISHED = "Finished"
CANCELLED = "Cancelled"
44 changes: 44 additions & 0 deletions apps/contests/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 4.2.5 on 2023-09-30 05:03

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="Contest",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("title", models.CharField(max_length=256)),
("description", models.CharField(max_length=1024)),
("start_time", models.DateTimeField()),
("end_time", models.DateTimeField()),
(
"users",
models.ManyToManyField(
related_name="contests", to=settings.AUTH_USER_MODEL
),
),
],
options={
"db_table": "contests",
},
),
]
17 changes: 17 additions & 0 deletions apps/contests/migrations/0002_contest_cancelled.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.5 on 2023-09-30 05:21

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("contests", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="contest",
name="cancelled",
field=models.BooleanField(default=False),
),
]
Empty file.
44 changes: 44 additions & 0 deletions apps/contests/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from django.db.models import (
BooleanField,
CharField,
DateTimeField,
ManyToManyField,
)
from django.utils.timezone import now

from apps.contests.enums import ContestStatus
from apps.users.models import User
from core.models import TimestampedModel


class Contest(TimestampedModel):
"""Represents a contest."""

id: int

title = CharField(max_length=256)
description = CharField(max_length=1024)

start_time = DateTimeField()
end_time = DateTimeField()
cancelled = BooleanField(default=False)

users = ManyToManyField(User, related_name="contests")

class Meta:
db_table = "contests"

def __str__(self) -> str:
return f"{self.title} #{self.id}"

@property
def status(self) -> ContestStatus:
if self.cancelled:
return ContestStatus.CANCELLED

if self.start_time > now():
return ContestStatus.PENDING
elif self.end_time < now():
return ContestStatus.FINISHED
else:
return ContestStatus.RUNNING
9 changes: 9 additions & 0 deletions apps/contests/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path

from apps.contests.views import DetailView

app_name = "contests"

urlpatterns = [
path("<int:pk>/", DetailView.as_view(), name="detail"),
]
33 changes: 33 additions & 0 deletions apps/contests/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import TYPE_CHECKING, Any

from django.db.models.query import QuerySet
from django.views import generic

from apps.contests.enums import ContestStatus
from apps.contests.models import Contest

if TYPE_CHECKING:
IndexViewBase = generic.ListView[Contest]
DetailViewBase = generic.DetailView[Contest]
else:
IndexViewBase = generic.ListView
DetailViewBase = generic.DetailView


class IndexView(IndexViewBase):
template_name = "contests/index.html"
context_object_name = "contests"

def get_queryset(self) -> QuerySet[Contest]:
return Contest._default_manager.order_by("start_time")[:5]

def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
ctx = super().get_context_data(**kwargs)
ctx["valid_statuses"] = (ContestStatus.PENDING, ContestStatus.RUNNING)

return ctx


class DetailView(DetailViewBase):
model = Contest
template_name = "contests/detail.html"
8 changes: 8 additions & 0 deletions apps/problems/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig

default_app_config = "apps.problems.ProblemsConfig"


class ProblemsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.problems"
44 changes: 44 additions & 0 deletions apps/problems/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from typing import TYPE_CHECKING

from django.contrib.admin import ModelAdmin, register
from django.forms import CharField, IntegerField, ModelForm, Textarea
from django.utils.translation import gettext_lazy as _

from apps.problems.models import Problem

if TYPE_CHECKING:
ProblemAdminBase = ModelAdmin[Problem]
ProblemModelFormBase = ModelForm[Problem]
else:
ProblemAdminBase = ModelAdmin
ProblemModelFormBase = ModelForm


class ProblemModelForm(ProblemModelFormBase):
description = CharField(widget=Textarea(attrs={"rows": 14, "cols": 80}))
score = IntegerField(min_value=0, required=False)

memory_limit = IntegerField(
min_value=0, required=False, help_text=_("In bytes.")
)
time_limit = IntegerField(
min_value=0, required=False, help_text=_("In seconds.")
)

class Meta:
model = Problem
fields = "__all__"


@register(Problem)
class ProblemAdmin(ProblemAdminBase):
form = ProblemModelForm

list_display = ("title", "contest", "memory_limit", "time_limit")
list_filter = ("contest", "score")

fieldsets = [
(_("General"), {"fields": ("title", "description")}),
(_("Meta"), {"fields": ("contest", "score")}),
(_("Limits"), {"fields": ("memory_limit", "time_limit")}),
]
45 changes: 45 additions & 0 deletions apps/problems/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 4.2.5 on 2023-10-03 12:48

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = [
("contests", "0002_contest_cancelled"),
]

operations = [
migrations.CreateModel(
name="Problem",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("title", models.CharField(max_length=256)),
("description", models.CharField(max_length=4096)),
(
"contest",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="problems",
to="contests.contest",
),
),
],
options={
"ordering": ["-created_at", "-updated_at"],
"abstract": False,
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.5 on 2023-10-03 17:07

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("problems", "0001_initial"),
]

operations = [
migrations.AlterModelOptions(
name="problem",
options={},
),
migrations.AlterModelTable(
name="problem",
table="problems",
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.5 on 2023-10-04 22:05

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("problems", "0002_alter_problem_options_alter_problem_table"),
]

operations = [
migrations.AddField(
model_name="problem",
name="memory_limit",
field=models.IntegerField(null=True),
),
migrations.AddField(
model_name="problem",
name="score",
field=models.IntegerField(null=True),
),
migrations.AddField(
model_name="problem",
name="time_limit",
field=models.IntegerField(null=True),
),
]
Empty file.
Loading