diff --git a/label_studio/users/product_tours/serializers.py b/label_studio/users/product_tours/serializers.py index f512c12812bc..18e3bb02959a 100644 --- a/label_studio/users/product_tours/serializers.py +++ b/label_studio/users/product_tours/serializers.py @@ -1,10 +1,14 @@ +import logging import pathlib -import yaml from functools import cached_property + +import yaml from core.utils.db import fast_first from rest_framework import serializers -from .models import ProductTourInteractionData, UserProductTour +from .models import ProductTourInteractionData, ProductTourState, UserProductTour + +logger = logging.getLogger(__name__) PRODUCT_TOURS_CONFIGS_DIR = pathlib.Path(__file__).parent / 'configs' @@ -36,18 +40,19 @@ def load_tour_config(self): filepath = PRODUCT_TOURS_CONFIGS_DIR / f'{self.context["name"]}.yml' with open(filepath, 'r') as f: return yaml.safe_load(f) - + def get_awaiting(self, obj): - config = self.load_tour_config() + config = self.load_tour_config dependencies = config.get('dependencies', []) for dependency in dependencies: tour = fast_first(UserProductTour.objects.filter(user=self.context['request'].user, name=dependency)) - if not tour or tour.status != UserProductTour.Status.COMPLETED: + if not tour or tour.state != ProductTourState.COMPLETED: + logger.info(f'Tour {dependency} is not completed: skipping tour {self.context["name"]}') return True return False def get_steps(self, obj): - config = self.load_tour_config() + config = self.load_tour_config return config.get('steps', []) def validate_interaction_data(self, value):