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

Commit

Permalink
feat(validators): contest views validator
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizaMaluf committed Nov 15, 2023
1 parent 12c69c9 commit 9996f17
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apps/contests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ def get_queryset(self) -> QuerySet[Contest]:
start_time__gte=timezone.now()
).order_by("start_time")[:5]
if not queryset.exists():
raise ValidationError("Não há concursos futuros disponíveis.")
raise ValidationError("There are no future contests available.")
return queryset

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

valid_statuses = (ContestStatus.PENDING, ContestStatus.RUNNING)
if not all(status in ContestStatus for status in valid_statuses):
raise ValidationError(
"Defina pelo menos dois estados de concurso válidos."
)
raise ValidationError("Define at least two valid contest states.")

ctx["valid_statuses"] = valid_statuses

Expand Down

0 comments on commit 9996f17

Please sign in to comment.