From 7c2c59dd8387ca52c5c0dc3c8daafb5253167d9d Mon Sep 17 00:00:00 2001 From: Mardone Date: Fri, 3 Nov 2023 14:08:19 -0300 Subject: [PATCH] fix examples language --- bothub/api/v2/examples/views.py | 5 ++--- bothub/api/v2/repository/serializers.py | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bothub/api/v2/examples/views.py b/bothub/api/v2/examples/views.py index 19a416af..c96cca14 100644 --- a/bothub/api/v2/examples/views.py +++ b/bothub/api/v2/examples/views.py @@ -99,7 +99,6 @@ def search_repositories_examples(self, request, **kwargs): } ) - @action( detail=True, methods=["GET"], @@ -108,7 +107,7 @@ def search_repositories_examples(self, request, **kwargs): def get_untrained_examples(self, request, **kwargs): repository_uuid = request.data.get("repository_uuid") user = request.user - + if len(RepositoryAuthorization.objects.filter(user=user, repository__uuid=repository_uuid)) == 0: raise PermissionDenied("You don't have permission on that repository.") @@ -117,7 +116,7 @@ def get_untrained_examples(self, request, **kwargs): repository = Repository.objects.get(uuid=repository_uuid) except: raise NotFound("Repository does not exists") - + repository_version = RepositoryVersion.objects.get(repository=repository) response = [] for repository_language in repository_version.version_languages.all(): diff --git a/bothub/api/v2/repository/serializers.py b/bothub/api/v2/repository/serializers.py index 4d95f6f2..87f5da8d 100644 --- a/bothub/api/v2/repository/serializers.py +++ b/bothub/api/v2/repository/serializers.py @@ -1391,13 +1391,14 @@ def create(self, validated_data): def update(self, instance, validated_data): entities_data = validated_data.pop("entities", None) validated_data.pop("repository", None) - validated_data.pop("repository_version_language", None) + version_id = validated_data.pop("repository_version_language", None) language = validated_data.pop("language", None) intent_text = validated_data.get("intent", None) if language: - repository_version_language = instance.repository_version_language.repository_version.repository.current_version( - language + repository_version_language = instance.repository_version_language.repository_version.repository.get_specific_version_id( + language=language, + repository_version=version_id.pk, ) validated_data.update( {"repository_version_language": repository_version_language}