예제 #1
0
def meeting(client_id, reunion_id):
    client = Client.objects.get(contact_id=client_id)
    reunion = Reunion.objects.get(id=reunion_id)

    raw_suggestions = get_suggested_products(client)
    products = map(lambda x: Product.objects.get(product_id=x[0]), raw_suggestions)

    return render_template('meeting.html', client=client, reunion=reunion, products=products)
예제 #2
0
def client_detail(client_id):
    client = Client.objects.get(contact_id=client_id)

    # suggestions
    raw_suggestions = get_suggested_products(client)
    suggestions = map(lambda x: (Product.objects.get(product_id=x[0]), x[1]), raw_suggestions)
    magic_number = 4
    recommendations = map(lambda x: x[0], suggestions[magic_number:])
    risqued = []
    sum_ = 0
    for sugg in suggestions[:-magic_number]:
        if sugg[0] in recommendations:
            continue
        risqued.append(sugg)
    max_abs = max(map(lambda x: abs(x[1]), risqued))
    risqued = map(lambda x: (x[0], int(100*(0.2 + 0.7*abs(x[1])/float(2*max_abs)))), risqued)
    print recommendations
    print risqued

    # meetings
    all_meetings = client.reunions
    scheduled_meetings = [x for x in all_meetings if x.date > datetime.datetime.now()]
    passed_meetings = [x for x in all_meetings if x not in scheduled_meetings]
    return render_template('client_detail.html', **locals())