Skip to content

Commit b635125

Browse files
committed
allow for any character in Channel route & make group name Classroom's and Channels's ids
1 parent 09146de commit b635125

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

classroom/consumers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def check_user_classroom(self, user, classroom):
2121
async def connect(self):
2222
classroom_code = self.scope["url_route"]["kwargs"]["classroom_code"]
2323
channel_name = self.scope["url_route"]["kwargs"]["channel_name"]
24-
self.group_name = classroom_code + "." + channel_name.replace(' ', '')
2524

2625
try:
2726
self.classroom = await database_sync_to_async(Classroom.objects.get)(code=classroom_code,)
@@ -33,6 +32,8 @@ async def connect(self):
3332
except:
3433
return await self.close()
3534

35+
self.group_name = str(self.classroom.id) + "." + str(self.channel.id)
36+
3637
if await self.check_user_classroom(self.scope['user'], self.classroom):
3738
return await self.close()
3839

classroom/routing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from . import consumers
33

44
websocket_urlpatterns = [
5-
re_path(r'ws/(?P<classroom_code>\w+)/(?P<channel_name>[\w\s]+)/$', consumers.ChannelConsumer.as_asgi())
5+
re_path(r'ws/(?P<classroom_code>\w+)/(?P<channel_name>.+)/$', consumers.ChannelConsumer.as_asgi())
66
]

0 commit comments

Comments
 (0)