def resolve_battles(**kwargs): """ Resolve a consulta de battles. """ if 'leader__id__in' in kwargs.keys(): global_ids = kwargs.pop('leader__id__in') leader_ids = [validate_global_id(i, 'LeaderType') for i in global_ids] kwargs['leader__id__in'] = leader_ids if 'trainer__id__in' in kwargs.keys(): global_ids = kwargs.pop('trainer__id__in') trainer_ids = [ validate_global_id(i, 'TrainerType') for i in global_ids ] kwargs['trainer__id__in'] = trainer_ids return Battle.objects.filter(**kwargs)
def resolve_leaders(**kwargs): """ Resolve a consulta de líderes. """ if 'id' in kwargs.keys(): leader_id = validate_global_id(kwargs.pop('id'), 'LeaderType') kwargs['id'] = leader_id return Leader.objects.filter(**kwargs)
def resolve_trainers(**kwargs): """ Resolve a consulta de treinadores. """ if 'id' in kwargs.keys(): trainer_id = validate_global_id(kwargs.pop('id'), 'TrainerType') kwargs['id'] = trainer_id return Trainer.objects.filter(**kwargs)
def resolve_leagues(**kwargs): """ Resolve a consulta de ligas. """ league_global_id = kwargs.get('id') if league_global_id: if 'id' in kwargs.keys(): league_id = validate_global_id(kwargs.pop('id'), 'LeagueType') kwargs['id'] = league_id return League.objects.filter(**kwargs)