Skip to content

Commit

Permalink
Merge pull request #14 from mcpt/main
Browse files Browse the repository at this point in the history
update cert
  • Loading branch information
JasonLovesDoggo authored Apr 6, 2024
2 parents ca1d657 + 664b975 commit bc9cebf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
18 changes: 18 additions & 0 deletions gameserver/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ninja import NinjaAPI, Schema
from typing import List, Any

import datetime

def unicode_safe(string):
return string.encode("unicode_escape").decode()
Expand All @@ -14,6 +15,16 @@ def unicode_safe(string):
api = NinjaAPI()


class ContestOutSchema(Schema):
name: str
slug: str
start_time: datetime.datetime
end_time: datetime.datetime
max_team_size: int | None
description: str
summary: str


class CTFSchema(Schema):
pos: int
team: Any = None
Expand Down Expand Up @@ -73,3 +84,10 @@ def ctftime_standings(request, contest_name: str):
)

return {"standings": standings, "tasks": task_names}

@api.get("/contests", response=List[ContestOutSchema])
def contests(request):
return (
Contest.objects.filter(is_public=True)
.values("name", "slug", "start_time", "end_time", "max_team_size", "description", "summary")
)
5 changes: 2 additions & 3 deletions gameserver/models/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@


class ResetableCache(Protocol):
def can_reset(cls, request: HttpRequest) -> None:
...
def can_reset(cls, request: HttpRequest) -> None: ...


class CacheMeta(models.Model):
Expand All @@ -43,7 +42,7 @@ def _can_reset(cls, request: HttpRequest):
[
request.user.is_authenticated,
request.user.is_staff,
request.GET.get("reset", "") == "true",
request.GET.get("reset", "").casefold() == "true",
]
)

Expand Down
7 changes: 6 additions & 1 deletion gameserver/models/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def __init__(self, *args, **kwargs):

organizers = models.ManyToManyField("User", related_name="contests_organized", blank=True)
curators = models.ManyToManyField("User", related_name="contests_curated", blank=True)
organizations = models.ManyToManyField("Organization", related_name="contests", blank=True, help_text="Only users of these organizations can access the contest")
organizations = models.ManyToManyField(
"Organization",
related_name="contests",
blank=True,
help_text="Only users of these organizations can access the contest",
)

name = models.CharField(max_length=128)
slug = models.SlugField(unique=True, db_index=True)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "mCTF"
version = "1.0.5"
description = "A reusable CTF platform."
authors = ["Jason Cameron <[email protected]"]
authors = ["Jason Cameron <[email protected]>"]
readme = "README.md"

keywords = ["ctf", "jeopardy", "ctf-platform", "django"]
Expand Down

0 comments on commit bc9cebf

Please sign in to comment.