def add_pir(): PIR = request.form.to_dict(flat=False) TS = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S') print("[%s_APP-View-add_pir]: Received: %s %s" % (TS, type(PIR), PIR)) PIR['CATEGORY'] = PIR['CATEGORY'][0] PIR['DESC'] = PIR['DESC'][0] PIR['CLASS1'] = PIR['CLASS1'][0] PIR['CLASS2'] = PIR['CLASS2'][0] PIR['CLASS3'] = PIR['CLASS3'][0] PIR['Locations'] = [] PIR['Locations'].append( PIR['Location'][0] ) #TODO Need to get multiple locations but UI5 takes too long to render ComboBox PIR['References'] = [] for r in PIR['References']: PIR['References'].append(r) if check_user() == True: user = User(session["username"]) TS = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S') print("[%s_APP-View-add_pir]: Received: %s %s" % (TS, type(PIR), PIR)) newPIR = user.add_pir(PIR) TS = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S') print("[%s_APP-View-add_pir]: current session %s-%s-%s" % (TS, flask.g, session.get("username"), session.get("utype"))) flash("PIR-%s" % newPIR['GUID']) return jsonify(newPIR) else: flash("Log in to access PIR functionality.") return redirect(url_for("login"))