diff options
| author | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2015-03-31 12:47:36 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2015-03-31 12:47:45 -0400 |
| commit | 4474754c3eaf0050993801383e81bb58f7b550c3 (patch) | |
| tree | 5f3f2b3a18a26fd36c7eb9e9d71a9e9d0b83e5a1 /wedding.py | |
| parent | 625daf28d37732c7ab6ac7af5f9ef71cdb3adca5 (diff) | |
| download | wedding-website-4474754c3eaf0050993801383e81bb58f7b550c3.tar.gz | |
make sure Thibaut doesn't break the site anymore
Diffstat (limited to 'wedding.py')
| -rw-r--r-- | wedding.py | 33 |
1 files changed, 20 insertions, 13 deletions
@@ -78,21 +78,28 @@ def rsvp(): db = get_db() update_string = [] args = [] - for k, v in request.form.items(): - update_string.append("{0}=?".format(k)) - if k in ["rsvp", "plusone", "kids"]: - ## convert to integer - args.append(int(v)) - else: + for k in ['full_name', 'email', 'mailing', 'plusonename', 'kidsnames', 'comments']: + v = request.form.get(k) + if v: + update_string.append("{0}=?".format(k)) + args.append(v) + for k in ["rsvp", "plusone", "kids"]: + v = request.form.get(k, type=int) + if v: + update_string.append("{0}=?".format(k)) args.append(v) - update_string = ",".join(update_string) - query = "UPDATE guests set {0} , lastupdate=current_timestamp " \ - "WHERE user_name=?".format(update_string) - with db: - db.execute(query, tuple(args+[session['user_name']])) - flash(gettext("We have updated your information!")) - return redirect(url_for('rsvp')) + if update_string: + update_string = ",".join(update_string) + query = "UPDATE guests set {0} , lastupdate=current_timestamp " \ + "WHERE user_name=?".format(update_string) + with db: + db.execute(query, tuple(args+[session['user_name']])) + flash(gettext("We have updated your information!")) + return redirect(url_for('rsvp')) + else: + flash(gettext("We could not update your information!")) + return redirect(url_for('rsvp')) @app.route('/') @app.route('/home/') |
