def create(): form_errors = None conn, cur = get_sql() if request.method == 'POST': for k,v in request.form.iteritems(): print k,v form_errors = collect_form_errors(request.form) if not len(form_errors) > 1: form_items = {} for k, v in request.form.iteritems(): print "key = {} value = {}".format(k,v) if (k == 'editor1'): form_items['html'] = request.form[k] elif (k == 'file'): form_items['preview'] = request.form[k] elif (v != ''): form_items[k] = v form_items['author'] = session.get('current_user') form_items['date_added'] = int(time()) tid = insert_row('template', form_items, conn, cur) if not tid: return render_template('server_error.html') return redirect(url_for('templates.edit', tid=tid)) return render_template('templates/details.html', form_errors=form_errors)
def create(): form_errors = None conn, cur = get_sql() if request.method == "POST": form_errors = collect_form_errors(request.form) if not form_errors: form_items = {} for k, v in request.form.iteritems(): if v != "": form_items[k] = v form_items["author"] = session.get("current_user") form_items["date_added"] = int(time()) lid = insert_row("list", form_items, conn, cur) if not lid: return render_template("server_error.html") return redirect(url_for("lists.edit", lid=lid)) return render_template("lists/details.html", form_errors=form_errors, editing=False)
def create(): form_errors = None conn, cur = get_sql() companies = get_companies(conn, cur) staff = get_staff(conn, cur) if request.method == 'POST': form_errors = collect_form_errors(request.form) if not form_errors: form_items = {} for k, v in request.form.iteritems(): if (v != '' and k[len(k) - 3:] != 'sel'): form_items[k] = v form_items['author'] = session.get('current_user') form_items['date_added'] = int(time()) nid = insert_row('newsletter', form_items, conn, cur) if not nid: return render_template('server_error.html') return redirect(url_for('lists.index', nid=nid)) return render_template('newsletters/details.html', companies=companies, staff=staff, form_errors=form_errors)