diff --git a/chat/__init__.py b/chat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/chat/admin.py b/chat/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/chat/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/chat/apps.py b/chat/apps.py new file mode 100644 index 0000000..2fe899a --- /dev/null +++ b/chat/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ChatConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'chat' diff --git a/frontend/consumers.py b/chat/consumers.py similarity index 100% rename from frontend/consumers.py rename to chat/consumers.py diff --git a/chat/models.py b/chat/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/chat/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/frontend/routing.py b/chat/routing.py similarity index 100% rename from frontend/routing.py rename to chat/routing.py diff --git a/chat/tests.py b/chat/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/chat/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/chat/views.py b/chat/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/chat/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/frontend/static/js/views/Chat.js b/frontend/static/js/views/Chat.js index 0f2b71d..7d071b3 100644 --- a/frontend/static/js/views/Chat.js +++ b/frontend/static/js/views/Chat.js @@ -14,7 +14,7 @@ export default class extends AbstractView { if (data.type === 'chat') { let messages = document.getElementById('messages') - let username = data.username === null ? "NoName" : data.username; + let username = data.username === null || data.username.length <= 0 ? "NoName" : data.username; messages.insertAdjacentHTML('beforeend', `

${username}: ${data.message}

`) diff --git a/trancendence/asgi.py b/trancendence/asgi.py index 5608a42..a229228 100644 --- a/trancendence/asgi.py +++ b/trancendence/asgi.py @@ -10,7 +10,7 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ import os from channels.routing import ProtocolTypeRouter, URLRouter from channels.auth import AuthMiddlewareStack -import frontend.routing +import chat.routing from django.core.asgi import get_asgi_application @@ -20,7 +20,7 @@ application = ProtocolTypeRouter({ 'http':get_asgi_application(), 'websocket':AuthMiddlewareStack( URLRouter( - frontend.routing.websocket_urlpatterns + chat.routing.websocket_urlpatterns ) ) })