def smile(): form = VoteForm() if "randomNote" not in session: #this is temporary; once site gets up and going, will find better way to counter botting session["randomNote"] = toJSON(Note.getRandomNote()) if form.validate_on_submit(): tempNote = Note.getNote(session["randomNote"]["lookupId"]) if form.like.data: tempNote.update({"numLikes": tempNote.numLikes + 1}) elif form.dislike.data: tempNote.update({"numDislikes": tempNote.numDislikes + 1}) session.clear() return redirect('/smile') return render_template("smile.html", notez = Note.getNote(session["randomNote"]["lookupId"]), form=form)
def report(): form = ReportForm() ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr) #print(request.environ.get('HTTP_X_REAL_IP', request.remote_addr)) if form.validate_on_submit(): #form.method == 'POST' #request.get_json()["ip"] id = Note.getNote(session["randomNote"]["lookupId"]).lookupId comments = "" if request.form: comments = request.form["comments"] session.clear() msg = Message("Someone reported a post!", sender="*****@*****.**", recipients=["*****@*****.**"]) msg.body = "Note UUID: " + id + "\n" + "Comments: " + comments + "\n" + "IP Address: " + ip mail.send(msg) return render_template("success.html") try: return render_template("report.html", form=form, note=Note.getNote(session["randomNote"]["lookupId"]), ip=ip) except: return render_template("error/403.html"), 403