# Path: family_tree/models/relation.py
# PARTNERED = 1
# 
# RAISED = 2
# 
# RAISED_BY = 3


from family_tree.models import Relation
from family_tree.models.relation import PARTNERED, RAISED, RAISED_BY
import random
    '''
    Gets all the unrelated children of partner
    '''
    suggestions = []

    for second_relation in relations_by_person[partner_id]:

        if  second_relation.relation_type == RAISED and \
            not _is_related(person_id, second_relation.to_person_id, relations_by_person) and \
            second_relation.to_person_id != person_id:

            relation = Relation(from_person_id = person_id, to_person_id = second_relation.to_person_id, relation_type = RAISED)

            suggestions.append(relation)

    return suggestions


def _get_unrelated_parents_of_child(person_id, child_id, relations_by_person):
    '''
    Gets all the unrelated parents of child
    '''
    suggestions = []

    for second_relation in relations_by_person[child_id]:

        if  second_relation.relation_type == RAISED_BY and \
            not _is_related(person_id, second_relation.to_person_id, relations_by_person) and \
            second_relation.to_person_id != person_id:


# Path: family_tree/models/relation.py
# PARTNERED = 1
# 
# RAISED = 2
# 
# RAISED_BY = 3


# Path: family_tree/services/relation_suggestion_service.py
from family_tree.models import Relation
from family_tree.models.relation import PARTNERED, RAISED, RAISED_BY
import random

    '''
    Gets all the unrelated children of partner
    '''
    suggestions = []

    for second_relation in relations_by_person[partner_id]:

        if  second_relation.relation_type == RAISED and \
            not _is_related(person_id, second_relation.to_person_id, relations_by_person) and \
            second_relation.to_person_id != person_id:

            relation = Relation(from_person_id = person_id, to_person_id = second_relation.to_person_id, relation_type = RAISED)

            suggestions.append(relation)

    return suggestions


def _get_unrelated_parents_of_child(person_id, child_id, relations_by_person):
    '''
    Gets all the unrelated parents of child
    '''
    suggestions = []

    for second_relation in relations_by_person[child_id]:

        if  second_relation.relation_type == RAISED_BY and \
            not _is_related(person_id, second_relation.to_person_id, relations_by_person) and \
            second_relation.to_person_id != person_id:


            relation = Relation(from_person_id = person_id, to_person_id = second_relation.to_person_id, relation_type = PARTNERED)