def send_recommender_reminder(request, recommender_id):
    try:
        request.user.applicant
    except:
        return HttpResponseRedirect(reverse('index'))
    user = User.objects.get(id = request.user.id)
    applicant = user.applicant
    recommender = Recommender.objects.get(id = recommender_id)
    if request.method == "POST":
        recommendation_requested_existing_recommender(user.id, recommender.id)
        recommendation_request_sent(user.id, recommender.id)
        return HttpResponseRedirect(reverse('reminder_sent'))
    return render(request, "send_recommender_reminder.html", {'recommender': recommender})
def add_recommender(email, first_name, last_name, applicant):
    applicant = Applicant.objects.get(id = applicant.id)
    rec_user = User.objects.filter(email = email).first()
    if not rec_user:
        if len(email)>30:
            username = email[0:30]
        else:
            username = email
        rec_user = User(username = username, first_name = first_name, last_name = last_name, email = email)
        password = generate_password()
        rec_user.set_password(password)
        rec_user.save()
        recommender = Recommender(user = rec_user, role=2)
        recommender.save()
        recommendation_requested(applicant.user.id, recommender.id, password)
    else:
        recommender = Recommender.objects.filter(user_id = rec_user.id).first()
        if not recommender:
            recommender = Recommender(user = rec_user, role=2)
            recommender.save()
        recommendation_requested_existing_recommender(applicant.user.id, recommender.id)
    recommendation = Recommendation(applicant = applicant, recommender = recommender)
    recommendation.save()