def post_help_request(): form = RequestForm() if form.validate_on_submit(): address = form.address.data location = get_location(address) Request.add({ "name": form.name.data, "phone": form.phone.data, "address": address, "latitude": location["lat"], "longitude": location["lng"], "category": form.category.data, "request": form.request.data }) flash('You request was successfully saved !', "success") # return redirect(url_for('login.login')) return render_template("get_help.html", form=form)
def post_request(): result = request.get_json().get("queryResult") data = result.get("parameters") context_parameters = result["outputContexts"][0].get("parameters") phone = context_parameters.get('caller_id', '') address = data["address"]["city"] + " " + data["address"]["street-address"] location = get_location(address) Request.add({ "name": data["name"]["name"], "phone": phone, "address": address, "latitude": location["lat"], "longitude": location["lng"], "category": data["service"], "request": "" }) return "OK"
def make_request(): data = edict(request.get_json()) # data should only contain request type # Check that it is not the same request as an existing one (e.g same user, same room, same request) call_request = Request.query.filter_by(caller=current_user, room=current_user.room, request=data.request).first() if call_request is None: call_request = Request.add(current_user, data) response = jsonify({ "request_id": call_request and call_request.id, "index": call_request and call_request.rank }) Request.check_match_in_room(current_user.room) return response