diff --git a/backend/console/models.py b/backend/console/models.py index fb7bc0c..bf0ea41 100644 --- a/backend/console/models.py +++ b/backend/console/models.py @@ -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( diff --git a/backend/console/serializers.py b/backend/console/serializers.py index 41ec5fc..9c42a6d 100644 --- a/backend/console/serializers.py +++ b/backend/console/serializers.py @@ -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 @@ -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 @@ -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): diff --git a/backend/console/views.py b/backend/console/views.py index 4bfca28..4f91965 100644 --- a/backend/console/views.py +++ b/backend/console/views.py @@ -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'):