from models import Lead, Communication

def update_email_response(communication_plus_check=None, lead_plus_check=None, link_plus_check=None):
    communication = None
    lead = None
    try:
        communication = Communication.objects.get(id=communication_plus_check[:-3])
    except:
        pass
    
    try:
        lead = Lead.objects.get(id=lead_plus_check[:-3])
    except:
        pass
    
    if communication and lead:
        if communication.short_check_code() == communication_plus_check[-3:] and lead.short_check_code() == lead_plus_check[-3:]:
            lead.update_email_response(int(communication_plus_check[:-3]))
            return True
    return False

