emile 10 months ago
parent 59d67ac89d
commit 4bdf4cecf3

Binary file not shown.

@ -49,17 +49,24 @@ class OnlineUserConsumer(WebsocketConsumer):
customer_connections = [] customer_connections = []
staff_connections = [] staff_connections = []
for connection in sorted_connections: for connection in sorted_connections:
if hasattr(connection.user, 'customerprofile'):
connection_data = { connection_data = {
'user_id': connection.user.id, 'first_name': connection.user.first_name,
'username': connection.user.username, 'last_name': connection.user.last_name,
'last_seen': connection.last_seen.isoformat() if connection.last_seen else None 'last_seen': connection.user.customerprofile.get_last_seen,
'online': connection.online
} }
if hasattr(connection.user, 'customerprofile'):
customer_connections.append(connection_data) customer_connections.append(connection_data)
elif hasattr(connection.user, 'staffprofile'): elif hasattr(connection.user, 'staffprofile'):
connection_data = {
'first_name': connection.user.first_name,
'last_name': connection.user.last_name,
'last_seen': connection.user.staffprofile.get_last_seen,
'image': connection.user.staffprofile.image.url,
'online': connection.online
}
staff_connections.append(connection_data) staff_connections.append(connection_data)
print(staff_connections)
event = { event = {
'type': 'online_user_connection_handler', 'type': 'online_user_connection_handler',
'staff_connections': staff_connections, 'staff_connections': staff_connections,

@ -19,17 +19,17 @@
<div class="w-full flex justify-start items-center gap-2"> <div class="w-full flex justify-start items-center gap-2">
<div class="relative"> <div class="relative">
<div class="w-[40px] h-[40px] rounded-full"> <div class="w-[40px] h-[40px] rounded-full">
<img src="{{staff_connection.user.staffprofile.image.url}}" <img src="{{staff_connection.image}}"
class="w-full h-full object-cover rounded-full"> class="w-full h-full object-cover rounded-full">
</div> </div>
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col">
<p class="text-secondosiblue text-sm">{{staff_connection.user.first_name}} <p class="text-secondosiblue text-sm">{{staff_connection.first_name}}
{{staff_connection.user.last_name}}</p> {{staff_connection.last_name}}</p>
{% if staff_connection.online %} {% if staff_connection.online %}
<p class="text-green-700 text-xs">Online</p> <p class="text-green-700 text-xs">Online</p>
{% else %} {% else %}
<p class="text-gray-500 text-xs">{{staff_connection.user.staffprofile.get_last_seen}}</p> <p class="text-gray-500 text-xs">{{staff_connection.last_seen}}</p>
{% endif %} {% endif %}
</div> </div>
@ -50,16 +50,16 @@
<div class="w-full flex justify-start items-center gap-2"> <div class="w-full flex justify-start items-center gap-2">
<div <div
class="w-[40px] h-[40px] bg-secondosiblue flex justify-center items-center rounded-full text-white"> class="w-[40px] h-[40px] bg-secondosiblue flex justify-center items-center rounded-full text-white">
<p>{{customer_connection.user.first_name|slice:":1"}}{{customer_connection.user.last_name|slice:":1"}} <p>{{customer_connection.first_name|slice:":1"}}{{customer_connection.last_name|slice:":1"}}
</p> </p>
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col">
<p class="text-secondosiblue text-sm">{{customer_connection.user.first_name}} <p class="text-secondosiblue text-sm">{{customer_connection.first_name}}
{{customer_connection.user.last_name}}</p> {{customer_connection.last_name}}</p>
{% if customer_connection.online %} {% if customer_connection.online %}
<p class="text-green-700 text-xs">Online</p> <p class="text-green-700 text-xs">Online</p>
{% else %} {% else %}
<p class="text-gray-500 text-xs"> {{customer_connection.user.customerprofile.get_last_seen}}</p> <p class="text-gray-500 text-xs"> {{customer_connection.last_seen}}</p>
{% endif %} {% endif %}
</div> </div>
</div> </div>

Loading…
Cancel
Save