Skip to content

Commit

Permalink
[UPD] Updated the avatar field, we implemented livepeer video
Browse files Browse the repository at this point in the history
  • Loading branch information
pathfindermilan committed Oct 22, 2024
1 parent 5e5aab3 commit 325da1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backend/console/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Identity(models.Model):

voice = models.CharField(max_length=9, choices=VOICE_CHOICES, default=VOICE_ADAM)

avatar = models.ImageField(upload_to='avatars/', null=True, blank=True)
avatar = models.URLField(max_length=200, null=True, blank=True)

class Behaviour(models.Model):
agent_greeting = models.CharField(
Expand Down
22 changes: 11 additions & 11 deletions backend/console/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ def create(self, validated_data):
customer=customer_instance,
**validated_data
)
avatar_instance = order.agent.identity.avatar
if avatar_instance:
_ , avatar_file_name = avatar_instance.name.split('/')
avatar_new_name = f"{order.id}__{avatar_file_name}"
# avatar_instance = order.agent.identity.avatar
# if avatar_instance:
# _ , avatar_file_name = avatar_instance.name.split('/')
# avatar_new_name = f"{order.id}__{avatar_file_name}"

with avatar_instance.open('rb') as f:
avatar_content = f.read()
avatar_instance.delete(save=False)
avatar_instance.save(avatar_new_name, ContentFile(avatar_content), save=False)
order.agent.identity.save()
# with avatar_instance.open('rb') as f:
# avatar_content = f.read()
# avatar_instance.delete(save=False)
# avatar_instance.save(avatar_new_name, ContentFile(avatar_content), save=False)
# order.agent.identity.save()

try:
fileitem_instance = order.agent.knowledge.knowledgefileitem.file_item
Expand Down Expand Up @@ -316,7 +316,7 @@ class Meta:

def get_avatar(self, order):
avatar_field = getattr(order.agent.identity, 'avatar', None)
return avatar_field.url if avatar_field else None
return avatar_field if avatar_field else None

def get_agent_name(self, order):
return getattr(order.agent.identity, 'agent_name', None) if order.agent.identity else None
Expand Down Expand Up @@ -365,7 +365,7 @@ def get_identity(self, order):
'agent_name': identity_field.agent_name,
'language': identity_field.language,
'voice': identity_field.voice,
'avatar': identity_field.avatar.url if identity_field.avatar else None
'avatar': identity_field.avatar if identity_field.avatar else None
}

def get_behaviour(self, order):
Expand Down
4 changes: 2 additions & 2 deletions backend/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def perform_destroy(self, instance):
if instance.agent:
if hasattr(instance.agent, 'identity'):
identity = instance.agent.identity
if identity.avatar:
identity.avatar.delete(save=False)
# if identity.avatar:
# identity.avatar.delete(save=False)
identity.delete()

if hasattr(instance.agent, 'behaviour'):
Expand Down

0 comments on commit 325da1b

Please sign in to comment.