add database to chatbox

This commit is contained in:
cuom1999 2020-03-19 16:51:56 -06:00
parent cb8eb2689c
commit 112f2b57c3
14 changed files with 77 additions and 104 deletions

View file

@ -1,13 +1,12 @@
import chat_box.routing
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
import chat_box.routing
application = ProtocolTypeRouter({
# (http->django views is added by default)
'websocket': AuthMiddlewareStack(
URLRouter(
chat_box.routing.websocket_urlpatterns,
),
chat_box.routing.websocket_urlpatterns
)
),
})
})

View file

@ -503,6 +503,8 @@ TESTCASE_VISIBLE_LENGTH = 60
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440
MESSAGES_TO_LOAD = 15
ASGI_APPLICATION = 'dmoj.routing.application'
CHANNEL_LAYERS = {
'default': {
@ -511,4 +513,4 @@ CHANNEL_LAYERS = {
"hosts": [('0.0.0.0', 6379)],
},
},
}
}

View file

@ -1,4 +1,4 @@
from chat_box.views import ChatView, send
from chat_box.views import ChatView
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
@ -10,6 +10,8 @@ from django.urls import reverse
from django.utils.functional import lazystr
from django.utils.translation import ugettext_lazy as _
from django.views.generic import RedirectView
from django.contrib.auth.decorators import login_required
from judge.feed import AtomBlogFeed, AtomCommentFeed, AtomProblemFeed, BlogFeed, CommentFeed, ProblemFeed
from judge.forms import CustomAuthenticationForm
@ -25,7 +27,6 @@ from judge.views.select2 import AssigneeSelect2View, CommentSelect2View, Contest
ContestUserSearchSelect2View, OrganizationSelect2View, ProblemSelect2View, TicketUserSelect2View, \
UserSearchSelect2View, UserSelect2View
admin.autodiscover()
register_patterns = [
@ -368,8 +369,8 @@ urlpatterns = [
url(r'^custom_checker_sample/', about.custom_checker_sample, name='custom_checker_sample'),
url(r'^chat/', include([
url(r'^$', ChatView.as_view(), name='chat'),
url(r'send$', send, name='send_message')
url(r'^$', login_required(ChatView.as_view()), name='chat'),
])),
]