def add_nominee(): uid = session.get('osm_uid', None) isadmin = uid in config.ADMINS if not uid or not (config.STAGE.startswith('call') or isadmin): return redirect(url_for('login')) form = AddNomineeForm() form.category.choices = g.category_choices if form.validate(): if form.nomid.data.isdigit(): n = Nominee.get(Nominee.id == int(form.nomid.data)) if n.proposedby != uid and not isadmin: return redirect(url_for('edit_nominees')) else: n = Nominee() n.proposedby = session['osm_uid'] n.status = Nominee.Status.SUBMITTED if request.form.get('submit') == g.lang['deletenominee']: if n.id: n.status = Nominee.Status.DELETED n.save() else: form.populate_obj(n) n.save() return redirect(url_for('edit_nominees')) return 'Error in fields:\n{}'.format( '\n'.join(['{}: {}'.format(k, v) for k, v in form.errors.items()]))
def add_nominee(): if 'osm_token' not in session or not canvote(session['osm_uid']): return redirect(url_for('login')) form = AddNomineeForm() if form.validate(): if form.nomid.data.isdigit(): n = Nominee.get(Nominee.id == int(form.nomid.data)) else: n = Nominee() n.nomination = session['nomination'] n.proposedby = session['osm_uid'] form.populate_obj(n) n.save() return redirect(url_for('edit_nominees')) return 'Error in fields:\n{}'.format('\n'.join(['{}: {}'.format(k, v) for k, v in form.errors.items()]))
def add_nominee(): if 'osm_token' not in session or not canvote(session['osm_uid']): return redirect(url_for('login')) form = AddNomineeForm() if form.validate(): if form.nomid.data.isdigit(): n = Nominee.get(Nominee.id == int(form.nomid.data)) else: n = Nominee() n.nomination = session['nomination'] n.proposedby = session['osm_uid'] form.populate_obj(n) n.save() return redirect(url_for('edit_nominees')) return 'Error in fields:\n{}'.format('\n'.join( ['{}: {}'.format(k, v) for k, v in form.errors.items()]))