def thumbdown(email,blogtitle,blog_id): loginform = LoginForm() if 'user' in session and blog_id.__len__() == 32: ids = Users.id_one(blog_id)['_id'] if utils.email_is_valid(email) == True and blog_id == ids: dislikes = Users.querytitlei(blogtitle)['dislikes'] thdow(int(dislikes),blogtitle,blog_id) return render_template("dislikes.html") else: return redirect(url_for('login')) return redirect(url_for('login'))
def commentUser(blogtitle,email,blog_id): commentform = CommentForm() if utils.email_is_valid(email) == True and 'user' in session and blog_id.__len__() == 32: ids = Users.id_one(blog_id)["_id"] if email and blog_id == ids: commentform.title.data = blogtitle return render_template('comment.html',commentform=commentform) else: flash("check problem") return redirect(url_for('login')) flash('there is a problem with you information') return redirect(url_for('login'))
def delete(email,blogtitle,blog_id): loginform = LoginForm() if session['user'] == email and blog_id.__len__() == 32: ids = Users.id_one(blog_id)["_id"] if blog_id == ids: Database.delete("blogs",{"_id":blog_id}) flash("blog deleted") return redirect(url_for('login')) else: flash("not right") return redirect(url_for('login')) return redirect(url_for('login'))
def open(email,blogtitle,blog_id): if utils.email_is_valid(email) == True and blog_id.__len__() == 32: item = Users.bytitle_one(blogtitle) ids = Users.id_one(blog_id)["_id"] if session['user'] == email and ids == blog_id: items = Users.bytitle(blogtitle) return render_template('blogopen.html',items=items) else: flash("there is a problem contact Admin") return redirect(url_for('login')) flash("there is a problem please contact admin") return redirect(url_for('login'))
def commentdetails(blogtitle,email,blog_id): if blog_id.__len__() == 32: ids = Users.id_one(blog_id)['_id'] if blog_id == ids and ids != False: item = Users.bytitle_one(blogtitle) totalcomment = Users.allcomments(blogtitle) blogs = Users.bytitle(blogtitle) return render_template('totalcomment.html',totalcomment=totalcomment,blogs=blogs) else: flash(" big problem ") return redirect(url_for('login')) flash("big problem man") return redirect(url_for('login'))
def editeprocess(email,blogtitle,blog_id): editeform = EditeForm() loginform = LoginForm() database_email = Users.get_by_email(email)["email"] if editeform.validate_on_submit() == True and 'user' in session and session['user'] == email and blog_id.__len__() == 32: thins = Users.bytitle(blogtitle) ids = Users.id_one(blog_id)["_id"] for stuff in thins: if stuff['titleblog'] == blogtitle and stuff['email'] == session["user"] and blog_id == ids: description = editeform.description.data Database.updates("blogs",{"content":stuff['content']},{"$set": {"content":description}}) return render_template('editemessage.html') else: redirect(url_for('login')) flash("these are technical errors please try login again") return render_template('login.html',loginform=loginform)
def edite(email,titleblog,blog_id): properties = [] editeform = EditeForm() loginform = LoginForm() if 'user' in session and session['user'] == email and blog_id and utils.email_is_valid(email) == True and blog_id.__len__() == 32: data_id = Users.get_by_email(email)["_id"] content = Users.bytitle(titleblog) for stuffs in content: ids = Users.id_one(blog_id)["_id"] if session['user'] == email and blog_id == ids: editeform.description.data = stuffs['content'] return render_template('edite.html',editeform=editeform,email=email,blogtitle=titleblog,blog_id=blog_id) else: flash("checking problem") return redirect(url_for('login')) return redirect(url_for('login'))