1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-05-16 23:32:45 +00:00

Compare commits

..

36 Commits

Author SHA1 Message Date
Emmy D'Anello
bd416318ac
Fix unread messages count
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:35 +02:00
Emmy D'Anello
90bec6bf5e
Remove debug code
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:34 +02:00
Emmy D'Anello
ed5944e044
Linting
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:34 +02:00
Emmy D'Anello
a41c17576f
Store last visited channel in local storage
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:34 +02:00
Emmy D'Anello
80456f4da8
Add sort by unread messages option
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:34 +02:00
Emmy D'Anello
1a641cb2d7
Store what messages are read
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:34 +02:00
Emmy D'Anello
8f3929875f
Improve context menus
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:34 +02:00
Emmy D'Anello
f26f102650
Automatically create appropriated channels when tournaments/pools/participations are updated
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:34 +02:00
Emmy D'Anello
1e5d0ebcfc
Editing and deleting is working
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:33 +02:00
Emmy D'Anello
0cab21f344
Users can only edit & delete their own messages (except for admin users)
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:33 +02:00
Emmy D'Anello
a771710094
Add popovers to edit and delete messages
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:33 +02:00
Emmy D'Anello
3b3dcff28b
Only give the focus to a private channel if it wasn't previously created
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:33 +02:00
Emmy D'Anello
d6aa5eb0cc
Manage private chats
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:33 +02:00
Emmy D'Anello
c6b9a84def
Reset retry delay to 1 second when a connection has succeeded
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:33 +02:00
Emmy D'Anello
675f19492c
Extend session cookie age from 3 hours to 2 weeks
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:32 +02:00
Emmy D'Anello
a5c210e9b6
Add script to create channels per tournament, pools and teams. Put channels in categories
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:32 +02:00
Emmy D'Anello
784002c085
Open channels list by swiping
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:32 +02:00
Emmy D'Anello
e77cc558de
Add specific login and logout pages for chat
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:32 +02:00
Emmy D'Anello
7bb0f78f34
Improve mobile chat
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:32 +02:00
Emmy D'Anello
bfd1a76a2d
Notifications use the PNG logo
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:32 +02:00
Emmy D'Anello
b86dfe7351
Automatically scroll to bottom
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:32 +02:00
Emmy D'Anello
d36e97fa2e
Chat is restricted to authenticated users
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:31 +02:00
Emmy D'Anello
181bb86e49
Simplify chat views
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:31 +02:00
Emmy D'Anello
a121d1042b
Add feature to install chat on the home screen
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:31 +02:00
Emmy D'Anello
2d706b2b81
Add fullscreen mode for chat
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:31 +02:00
Emmy D'Anello
ca91842c2d
Fill channel selector using JavaScript
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:31 +02:00
Emmy D'Anello
d617dd77c1
Properly sort messages and add fetch previous messages ability
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:31 +02:00
Emmy D'Anello
d59bb75dce
Fetching last messages is working
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:30 +02:00
Emmy D'Anello
4a78e80399
Send messages
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:30 +02:00
Emmy D'Anello
f3a4a99b78
Setup chat UI
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:30 +02:00
Emmy D'Anello
46fc5f39c8
Allow to impersonate user on draw interface
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:30 +02:00
Emmy D'Anello
b464e7df1d
Manage channels permissions
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:30 +02:00
Emmy D'Anello
7498677bbd
Permissions are strings, not integers
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:30 +02:00
Emmy D'Anello
ea8007aa07
Initialize chat interface
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:29 +02:00
Emmy D'Anello
d9bb0a0860
Prepare models for new chat feature
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-29 00:39:29 +02:00
Emmy D'Anello
a594b268ea
Fix permission to download all authorizations of a tournament
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-25 12:42:37 +02:00
3 changed files with 8 additions and 8 deletions

View File

@ -3,7 +3,7 @@
from channels.generic.websocket import AsyncJsonWebsocketConsumer
from django.contrib.auth.models import User
from django.db.models import Count, Exists, OuterRef, Q
from django.db.models import Count, F, Q
from registration.models import Registration
from .models import Channel, Message
@ -93,7 +93,9 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
'unread_messages': channel.unread_messages,
}
async for channel in self.read_channels.prefetch_related('invited')
.annotate(unread_messages=Count('messages', filter=~Q(messages__users_read=user))).all()
.annotate(total_messages=Count('messages', distinct=True))
.annotate(read_messages=Count('messages', filter=Q(messages__users_read=user), distinct=True))
.annotate(unread_messages=F('total_messages') - F('read_messages')).all()
]
}
await self.send_json(message)
@ -160,8 +162,7 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
messages = Message.objects \
.filter(channel=channel) \
.annotate(read=Exists(User.objects.filter(pk=self.scope['user'].pk)
.filter(pk=OuterRef('users_read')))) \
.annotate(read=Count('users_read', filter=Q(users_read=self.scope['user']))) \
.order_by('-created_at')[offset:offset + limit].all()
await self.send_json({
'type': 'fetch_messages',
@ -173,7 +174,7 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
'author_id': message.author_id,
'author': await message.aget_author_name(),
'content': message.content,
'read': message.read,
'read': message.read > 0,
}
async for message in messages
]))
@ -239,7 +240,6 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
'content': message['content']})
async def chat_edit_message(self, message) -> None:
print(message)
await self.send_json({'type': 'edit_message', 'id': message['id'], 'channel_id': message['channel_id'],
'content': message['content']})

View File

@ -157,6 +157,7 @@ function fetchPreviousMessages() {
}
function receiveFetchedMessages(data) {
console.log(data)
let channel_id = data['channel_id']
let new_messages = data['messages']
@ -189,7 +190,6 @@ function updateUnreadBadges(unreadMessages) {
for (let channel of Object.values(channels)) {
let unreadMessagesChannel = unreadMessages[channel['id']] || 0
console.log(channel, unreadMessagesChannel)
channel.unread_messages = unreadMessagesChannel
let unreadBadge = document.getElementById(`unread-messages-${channel['id']}`)

View File

@ -391,7 +391,7 @@ class TeamAuthorizationsView(LoginRequiredMixin, View):
tournament = Tournament.objects.get(pk=kwargs["tournament_id"])
if user.registration.is_admin or user.registration.is_volunteer \
and (user.registration in tournament.organizers
and (user.registration in tournament.organizers.all()
or (team is not None and team.participation.final
and user.registration in Tournament.final_tournament().organizers)):
return super().dispatch(request, *args, **kwargs)