def createDemand(): """ The '/createDemand' route directs a client to the form where he/she can create and post a demand on the Turk System. """ if 'username' not in session: return redirect(url_for('login')) if session['role'] != 'client': return render_template('access_denied.html') form = DemandForm() if request.method == 'POST': if form.validate(): format = '%m-%d-%Y %I:%M %p' dt_bid = form.bidding_deadline.data.strftime(format) dt_submit = form.submission_deadline.data.strftime(format) Demand(session['username'], form.title.data, form.tags.data, form.specifications.data, dt_bid, dt_submit) new_demand_id = Demand.get_most_recent_demand_id() return redirect(url_for('bidInfo', demand_id=new_demand_id)) else: return render_template('createDemand.html', form=form) elif request.method == 'GET': return render_template('createDemand.html', form=form)