Bootstrap Weirsøe Party Protocol with initial game model and workflow

This commit is contained in:
2026-02-27 12:09:21 +01:00
commit fa1c951c8c
6010 changed files with 762251 additions and 0 deletions

0
partyhub/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

11
partyhub/asgi.py Normal file
View File

@@ -0,0 +1,11 @@
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'partyhub.settings')
django_asgi_app = get_asgi_application()
application = ProtocolTypeRouter({
'http': django_asgi_app,
})

109
partyhub/settings.py Normal file
View File

@@ -0,0 +1,109 @@
from pathlib import Path
import os
BASE_DIR = Path(__file__).resolve().parent.parent
def env(key: str, default: str | None = None) -> str | None:
return os.getenv(key, default)
SECRET_KEY = env('DJANGO_SECRET_KEY', 'dev-insecure-key-change-me')
DEBUG = env('DJANGO_DEBUG', 'true').lower() == 'true'
ALLOWED_HOSTS = [h.strip() for h in env('DJANGO_ALLOWED_HOSTS', '*').split(',') if h.strip()]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'channels',
'core_admin',
'fupogfakta',
'lobby',
'realtime',
'voice',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'partyhub.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'partyhub.wsgi.application'
ASGI_APPLICATION = 'partyhub.asgi.application'
DB_ENGINE = env('DB_ENGINE', 'django.db.backends.sqlite3')
if DB_ENGINE == 'django.db.backends.sqlite3':
DATABASES = {
'default': {
'ENGINE': DB_ENGINE,
'NAME': env('DB_NAME', str(BASE_DIR / 'db.sqlite3')),
}
}
else:
DATABASES = {
'default': {
'ENGINE': DB_ENGINE,
'NAME': env('DB_NAME', 'wpp_test'),
'USER': env('DB_USER', 'wpp_test'),
'PASSWORD': env('DB_PASSWORD', ''),
'HOST': env('DB_HOST', '127.0.0.1'),
'PORT': env('DB_PORT', '3306'),
'OPTIONS': {'charset': 'utf8mb4'},
}
}
TEST_DB_NAME = env('TEST_DB_NAME')
if TEST_DB_NAME:
DATABASES['default']['TEST'] = {'NAME': TEST_DB_NAME}
AUTH_PASSWORD_VALIDATORS = [
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'},
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'},
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
]
LANGUAGE_CODE = 'da'
TIME_ZONE = 'Europe/Copenhagen'
USE_I18N = True
USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CHANNEL_REDIS_HOST = env('CHANNEL_REDIS_HOST', '127.0.0.1')
CHANNEL_REDIS_PORT = int(env('CHANNEL_REDIS_PORT', '6379'))
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {'hosts': [(CHANNEL_REDIS_HOST, CHANNEL_REDIS_PORT)]},
}
}

13
partyhub/urls.py Normal file
View File

@@ -0,0 +1,13 @@
from django.contrib import admin
from django.http import JsonResponse
from django.urls import path
def health(_request):
return JsonResponse({'ok': True, 'service': 'weirsoe-party-protocol'})
urlpatterns = [
path('admin/', admin.site.urls),
path('healthz', health, name='healthz'),
]

16
partyhub/wsgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
WSGI config for partyhub project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'partyhub.settings')
application = get_wsgi_application()