def entry(): if request.method == 'POST': # print request.method, request.path # print request.form date = request.form['date_day'] + ":" + request.form[ 'date_month'] + ":" + request.form['date_year'] time = request.form['time_hour'] + ":" + request.form['time_minute'] duration = request.form['duration_hour'] + ":" + request.form[ 'duration_minute'] current_leg = 1 morelegs = True legs = [] while morelegs is True: mode_str = "mode_" + str(current_leg) rating_str = "rating_" + str(current_leg) hour_str = "leg_duration_hour_" + str(current_leg) min_str = "leg_duration_minute_" + str(current_leg) leg_mode = request.form.get(mode_str, False) if leg_mode is False: morelegs = False else: leg_duration = request.form[hour_str] + ":" + request.form[ min_str] leg = { "rating": request.form[rating_str], "mode": leg_mode, "duration": leg_duration, "no": current_leg } legs.append(leg) current_leg = current_leg + 1 idx = data.get_entry_count(datadb, session['uuid']) entry = { "id": str(idx + 1), "origin": request.form['origin'], "destination": request.form['destination'], "overall_rating": request.form['overall_rating'], "notes": request.form['notes'], "date": date, "time": time, "duration": duration, "legs": legs } data.add_entry(datadb, session['uuid'], entry) msg = gettext("Your journey entry was added to your diary") flash(msg) return redirect(url_for('.dashboard')) return render_template('entry.html')
def new_link(): link = request.form["link"] short = int(get_entries()[-1]["short"]) + 1 add_entry({ "link": link, "short": short }) return render_template("new_link.html", short=short)
def new_post(): title = request.form['title'] abstract = request.form['abstract'] content = request.form['content'] add_entry({ 'title': title, 'abstract': abstract, 'content': content }) return redirect('/')
def add_url(): long_url = request.form['long_url'] short_url = request.form['short_url'] nav = "Here is your short link!" if valid_long_url(long_url): if valid_short_url(short_url): add_entry(short_url[len(current_host):], long_url) else: new_link = generate_link() short_url = current_host + new_link add_entry(new_link, long_url, new_link) return render_template("link_added.html", Nav = nav, short_link = short_url)
def entry(): if request.method == 'POST': # print request.method, request.path # print request.form date = request.form['date_day'] +":"+ request.form['date_month'] +":"+ request.form['date_year'] time = request.form['time_hour'] +":"+ request.form['time_minute'] duration = request.form['duration_hour'] +":"+ request.form['duration_minute'] current_leg = 1 morelegs = True legs = [] while morelegs is True: mode_str = "mode_"+str(current_leg) rating_str = "rating_"+str(current_leg) hour_str = "leg_duration_hour_"+str(current_leg) min_str = "leg_duration_minute_"+str(current_leg) leg_mode = request.form.get(mode_str, False) if leg_mode is False: morelegs = False else: leg_duration = request.form[hour_str] +":"+ request.form[min_str] leg = {"rating": request.form[rating_str], "mode": leg_mode, "duration": leg_duration, "no": current_leg} legs.append(leg) current_leg = current_leg + 1 idx = data.get_entry_count(datadb, session['uuid']) entry = {"id": str(idx + 1), "origin": request.form['origin'], "destination": request.form['destination'], "overall_rating": request.form['overall_rating'], "notes": request.form['notes'], "date": date, "time": time, "duration": duration, "legs": legs} data.add_entry(datadb, session['uuid'], entry) msg = gettext("Your journey entry was added to your diary") flash(msg) return redirect( url_for('.dashboard') ) return render_template('entry.html')
def new_post(): title = request.form['title'] abstract = request.form['abstract'] content = request.form['content'] add_entry({'title': title, 'abstract': abstract, 'content': content}) return redirect(url_for('home'))