diff --git a/config/__pycache__/settings.cpython-313.pyc b/config/__pycache__/settings.cpython-313.pyc index 9cce306..196cc9c 100644 Binary files a/config/__pycache__/settings.cpython-313.pyc and b/config/__pycache__/settings.cpython-313.pyc differ diff --git a/config/api.py b/config/api.py index e0c8738..7db6dd0 100644 --- a/config/api.py +++ b/config/api.py @@ -1,8 +1,16 @@ from rest_framework.routers import DefaultRouter +from apps.domains.viewsets import DomainViewSet, OrganisationViewSet, DatasetViewSet from apps.users.viewsets import UserViewSet +from apps.agents.viewsets import AgentViewSet, AgentExecutionViewSet +from apps.users.urls import urlpatterns as user_urls router = DefaultRouter() -router.register(r'users', UserViewSet, basename = 'user') +router.register(r'domain', DomainViewSet, basename = 'domain') +router.register(r'organisation', OrganisationViewSet, basename = 'organisation') +router.register(r'dataset', DatasetViewSet, basename = 'dataset') +router.register(r'user', UserViewSet, basename = 'user') +router.register(r'agent', AgentViewSet, basename = 'agent') +router.register(r'agent-execution', AgentExecutionViewSet, basename = 'agent-execution') -urlpatterns = router.urls +urlpatterns = user_urls + router.urls diff --git a/config/asgi.py b/config/asgi.py index a00b3b5..d8798dd 100644 --- a/config/asgi.py +++ b/config/asgi.py @@ -1,7 +1,20 @@ import os - +from channels.routing import ProtocolTypeRouter, URLRouter +from channels.auth import AuthMiddlewareStack +from channels.security.websocket import AllowedHostsOriginValidator from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') -application = get_asgi_application() +django_asgi_app = get_asgi_application() + +from apps.agents.routing import websocket_urlpatterns + +application = ProtocolTypeRouter({ + "http": django_asgi_app, + "websocket": AllowedHostsOriginValidator( + AuthMiddlewareStack( + URLRouter(websocket_urlpatterns) + ) + ), +}) diff --git a/config/settings.py b/config/settings.py index 8c14e93..d695f52 100644 --- a/config/settings.py +++ b/config/settings.py @@ -8,7 +8,6 @@ load_dotenv(dotenv_path = BASE_DIR / '.env') BUILD_DIR = os.getenv('DJANGO_BUILD_DIR', BASE_DIR / 'build') - SECRET_KEY = os.getenv('DJANGO_SECRET_KEY') DEBUG = str(os.getenv('DJANGO_DEBUG')).lower() in ('1', 'true', 'yes', 'on') @@ -23,6 +22,7 @@ MEDIA_ROOT = os.getenv('DJANGO_MEDIA_ROOT', BASE_DIR / 'media') OVERRIDE_APPS = [ 'jazzmin', + 'daphne', ] DJANGO_APPS = [ 'django.contrib.admin', @@ -34,6 +34,7 @@ DJANGO_APPS = [ ] THIRD_PARTY_APPS = [ 'rest_framework', + 'channels', ] LOCAL_APPS = [ 'apps.users', @@ -42,7 +43,6 @@ LOCAL_APPS = [ ] INSTALLED_APPS = OVERRIDE_APPS + DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS - AUTH_USER_MODEL = 'users.User' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' @@ -61,6 +61,11 @@ ROOT_URLCONF = f'{PARENT_NAME}.urls' WSGI_APPLICATION = f'{PARENT_NAME}.wsgi.application' ASGI_APPLICATION = f'{PARENT_NAME}.asgi.application' +CHANNEL_LAYERS = { + 'default': { + 'BACKEND': 'channels.layers.InMemoryChannelLayer' + } +} TEMPLATES = [ { diff --git a/config/wsgi.py b/config/wsgi.py index e2fbd58..885c6e5 100644 --- a/config/wsgi.py +++ b/config/wsgi.py @@ -1,16 +1,5 @@ -""" -WSGI config for config 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/5.2/howto/deployment/wsgi/ -""" - import os - from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') - application = get_wsgi_application() diff --git a/requirements/base.txt b/requirements/base.txt index aa622d8..09e7848 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,6 +1,8 @@ asgiref==3.10.0 +celery==5.6.0 django==5.2.8 djangorestframework==3.16.1 +channels[daphne]==4.3.0 django-jazzmin==3.0.1 gunicorn==23.0.0 jinja2==3.1.6