Skip to content

Commit

Permalink
Feature/rollback room list fields (#401)
Browse files Browse the repository at this point in the history
* feat: add old fields on list room serializer

* feat: add flowstart_data

* feat: remove flowstart

* feat: remove flowstart

* feat: remove flowstart_data fomr list room
  • Loading branch information
helllllllder authored Oct 14, 2024
1 parent 2a0120e commit 3284c13
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions chats/apps/api/v1/rooms/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from chats.apps.accounts.models import User
from chats.apps.api.v1.accounts.serializers import UserSerializer
from chats.apps.api.v1.contacts.serializers import ContactRelationsSerializer
from chats.apps.api.v1.queues.serializers import QueueSerializer, QueueSimpleSerializer
from chats.apps.api.v1.queues.serializers import QueueSerializer
from chats.apps.api.v1.sectors.serializers import DetailSectorTagSerializer
from chats.apps.queues.models import Queue
from chats.apps.rooms.models import Room
Expand Down Expand Up @@ -89,14 +89,15 @@ def get_can_edit_custom_fields(self, room: Room):

class ListRoomSerializer(serializers.ModelSerializer):
user = serializers.SerializerMethodField()
queue = QueueSimpleSerializer(many=False, read_only=True)
contact = serializers.SerializerMethodField()
queue = serializers.SerializerMethodField()
unread_msgs = serializers.IntegerField(required=False, default=0)
last_message = serializers.CharField(read_only=True, source="last_message_text")
is_waiting = serializers.BooleanField()
is_24h_valid = serializers.BooleanField(
default=True, source="is_24h_valid_computed"
)

last_interaction = serializers.DateTimeField(read_only=True)
can_edit_custom_fields = serializers.SerializerMethodField()

Expand Down Expand Up @@ -130,6 +131,17 @@ def get_user(self, room: Room):
except AttributeError:
return None

def get_queue(self, room: Room):
try:
return {
"uuid": str(room.queue.uuid),
"name": room.queue.name,
"sector": str(room.queue.sector.uuid),
"sector_name": room.queue.sector.name,
}
except AttributeError:
return None

def get_contact(self, room: Room):
return {
"uuid": room.contact.uuid,
Expand Down

0 comments on commit 3284c13

Please sign in to comment.