def addBlog(): if ('username' in session and 'password' in session): user = session['username'] userid = readDB.getUserID(session['username']) #print(request.form) if('title' in request.form and request.form['title'] != ""): addDB.createBlog(int(readDB.getUserID(session['username'])), str(request.form['title'])) return redirect("/user/" + session['username']) return render_template('addBlog.html', user = user, userid = userid) return redirect(url_for("firstLogin"))
def editBlog(blogid, entrynum): if ('username' in session and 'password' in session): user = session['username'] userid = readDB.getUserID(session['username']) #print(request.form) if('entry' in request.form and request.form['entry'] != ""): addDB.editEntry(int(readDB.getUserID(session['username'])), blogid, entrynum, str(request.form['entry'])) return redirect("/user/" + session['username'] + "/blog/" + blogid) return render_template('editEntry.html', user = user, userid = userid, blogid = blogid, entrynum = entrynum, oldentry = readDB.getEntry(userid,blogid,entrynum)) return redirect(url_for("firstLogin"))
def blogPage(user,blogid): if ('username' in session and 'password' in session): userid = readDB.getUserID(user) entries = readDB.displayOnlyEntries(user, blogid) print(session) #print(entries) if (user == session["username"]): return render_template("blog.html", user = user, blogid = blogid, blogname = readDB.getBlogName(userid,blogid), myEntries = entries) return render_template("otherBlog.html", user = user, blogid = blogid, blogname = readDB.getBlogName(userid,blogid), theirEntries=entries) return redirect(url_for("firstLogin"))