Exemple #1
0
def home(request):
    context = RequestContext(request)
    context_dict = get_context_dict(request)

    menu_path = os.path.join(conf.settings.PROJECT_ROOT, 'menu.txt')
    menu = MenuParser(menu_path)
    menu = menu.parse_menu()
    preferences = context_dict['userprofile'].preferences
    preferences = Preferences.createFromString(preferences)
    matches = menu.match_with(preferences)
    html = ""
    for item in matches.get_items():  # TODO: make menu object iterable
        html += "<div style='margin-bottom: 4px; width: 400px; border-bottom: 1px solid #f0f0f0; float left;'>"
        html += "<strong>" + item.name + "</strong><br><font color='gray'>during " + item.meal + "</font><br><font color='gray'>at " + item.location + "</font>"
        html += "</div>"
    context_dict['matches'] = html
    return render_to_response("foodfinder/home.html", context_dict, context)