Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Final code fixes #87

Merged
merged 15 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ jobs:

- name: Execute Tests
run: |
py.test
pytest -vv
17 changes: 12 additions & 5 deletions ctfhub/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import datetime
from typing import Union
import django.http
from django.conf import settings

from ctfhub.models import Member


def add_debug_context(request: django.http.HttpRequest) -> dict[str, str]:
def add_debug_context(request: django.http.HttpRequest) -> dict[str, dict[str, str]]:
"""Adds some CTFHub environment information to every context

Args:
Expand All @@ -14,12 +16,17 @@ def add_debug_context(request: django.http.HttpRequest) -> dict[str, str]:
dict[str, str]: _description_
"""
return {
"DEBUG": settings.DEBUG,
"VERSION": settings.VERSION,
"CTFHub": {
"DEBUG": settings.DEBUG,
"VERSION": settings.PROJECT_VERSION,
"URL": settings.PROJECT_URL,
}
}


def add_timezone_context(request: django.http.HttpRequest) -> dict[str, str]:
def add_timezone_context(
request: django.http.HttpRequest,
) -> dict[str, Union[str, datetime.datetime]]:
"""Add the client timezone information to the HTTP context

Args:
Expand All @@ -30,6 +37,6 @@ def add_timezone_context(request: django.http.HttpRequest) -> dict[str, str]:
"""
try:
member = Member.objects.get(user=request.user)
return {"TZ": member.timezone}
return {"TZ": member.timezone, "NOW": datetime.datetime.now()}
except Exception:
return {"TZ": "UTC"}
55 changes: 0 additions & 55 deletions ctfhub/decorators/user.py

This file was deleted.

Loading