Ejemplo n.º 1
0
    def validate_uniqueness_except_current_tour_id(tour_id: int, field_name: str = None, **kwargs):
        tour = TourRepository.get_by(**kwargs)

        if tour is not None and tour.id != tour_id:
            key, value = next(iter(kwargs.items()))
            field_name = field_name if field_name else key

            raise ValidationError(field_name=field_name, message=ValidateErrorCode.IS_UNIQUE)

        return tour
Ejemplo n.º 2
0
    def validate_non_existence(field_name: str = None, **kwargs):
        tour = TourRepository.get_by(**kwargs)

        if tour is None:
            key, value = next(iter(kwargs.items()))
            field_name = field_name if field_name else key

            raise ValidationError(field_name=field_name, message=ValidateErrorCode.NOT_EXIST)

        return tour
Ejemplo n.º 3
0
    def validate_uniqueness(field_name: str = None, **kwargs):
        tour = TourRepository.get_by(**kwargs)

        if tour is not None:
            key, value = next(iter(kwargs.items()))
            field_name = field_name if field_name else key

            raise ValidationError(field_name=field_name, message=ValidateErrorCode.IS_UNIQUE)

        return tour
Ejemplo n.º 4
0
 def get_all_tour_payment_information(tour_id):
     tour = TourRepository.get_by(id=tour_id)
     if tour is None:
         raise TourNotFoundException
     return list(tour.tour_payment_informations)
Ejemplo n.º 5
0
 def is_existed(**kwargs) -> Tour:
     tour = TourRepository.get_by(**kwargs)
     return tour
Ejemplo n.º 6
0
    def is_existed_except_by_id(tour_id: int, **kwargs) -> bool:
        tour = TourRepository.get_by(**kwargs)

        if not tour or tour.id == tour_id:
            return False
        return True