def create_activity(item, mt, id_string): act = Activity() act.name = item['name'] act.polyline = item['map']['summary_polyline'] act.url = f'https://www.strava.com/activities/{item["id"]}' act.mountains.append(mt) act.activity_id = id_string act.date = item['start_date'] return act
def manual_entry(): if request.method == 'POST': if manual_entry_data_check(request.form['mountain'], request.form['date']): act = Activity() act.name = request.form['act_name'] act.polyline = None act.url = '/view/' + act.name mt = find_mountain(request.form['mountain']) act.mountains.append(mt) act.activity_id = None act.date = convert_date(request.form['date']) current_user.activities.append(act) act.description = request.form['description'] db.session.commit() flash("Peak Saved!") return redirect(url_for('index')) else: flash("Invalid Data") return render_template('manual_entry.html', title="Manual Entry", mt_list=appforms.mountain_choices())