def actionsDetail(id): user = session.get('username') actions_id = Actions.objects.with_id(id) allWordSave = Reviews.objects() numberOfWords = 0 for i in allWordSave: if i.username == user: numberOfWords += 1 if request.method == "GET": return render_template("actionsDetail.html", actions_id=actions_id, user=user, numberOfWords=numberOfWords) else: if user is not None: wordReview = Reviews(image=actions_id.image, word=actions_id.word, pronunciation=actions_id.pronunciation, mean=actions_id.mean, audio_link=actions_id.audio_link, username=user) wordReview.save() return redirect(url_for('actions')) else: flash('You must login first !') return render_template("actionsDetail.html", actions_id=actions_id, user=user, numberOfWords=numberOfWords)
def vegetablesAndFruitsDetail(id): user = session.get('username') vegetables_fruits_id = Vegetablesfruits.objects.with_id(id) # display number of words save in review allWordSave = Reviews.objects() numberOfWords = 0 for i in allWordSave: if i.username == user: numberOfWords += 1 if request.method == "GET": return render_template("vegetablesAndFruitsDetail.html", vegetables_fruits_id=vegetables_fruits_id, user=user, numberOfWords=numberOfWords) else: if user is not None: wordReview = Reviews( image=vegetables_fruits_id.image, word=vegetables_fruits_id.word, pronunciation=vegetables_fruits_id.pronunciation, mean=vegetables_fruits_id.mean, audio_link=vegetables_fruits_id.audio_link, username=user) wordReview.save() return redirect(url_for('vegetablesAndFruits')) else: flash('You must login first !') return render_template("vegetablesAndFruitsDetail.html", vegetables_fruits_id=vegetables_fruits_id, user=user, numberOfWords=numberOfWords)