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 actions(): user = session.get('username') allWordSave = Reviews.objects() numberOfWords = 0 for i in allWordSave: if i.username == user: numberOfWords += 1 list_audio = [] list_word = [] list_image = [] list_pronunciation = [] list_id = [] # get all document from dabase total_actions = Actions.objects() for i in total_actions: audio = i.audio_link word = i.word image = i.image pronunciation = i.pronunciation id = i.id list_audio.append(audio) list_word.append(word) list_image.append(image) list_pronunciation.append(pronunciation) list_id.append(id) return render_template("actions.html", list_audio=list_audio, list_word=list_word, list_image=list_image, list_pronunciation=list_pronunciation, list_id=list_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)
def learn(): user = session.get('username') allWordSave = Reviews.objects() numberOfWords = 0 for i in allWordSave: if i.username == user: numberOfWords += 1 return render_template("learn.html", user=user, numberOfWords=numberOfWords)
def detailVideo(youtube_id): user = session.get('username') allWordSave = Reviews.objects() numberOfWords = 0 for i in allWordSave: if i.username == user: numberOfWords += 1 return render_template("detailVideo.html", youtube_id=youtube_id, user=user, numberOfWords=numberOfWords)
def video(): user = session.get('username') allWordSave = Reviews.objects() numberOfWords = 0 for i in allWordSave: if i.username == user: numberOfWords += 1 videos = Video.objects() return render_template("videos.html", videos=videos, user=user, numberOfWords=numberOfWords)