Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
class testReviews(unittest.TestCase):
    """this test class is for testing the class Reviews"""
    def setUp(self):
        self.review = Reviews(1, 1, 1, 'currentuser', 'your business is thrilling')    

    def test_reviewInstance(self):
        review = Reviews(1, 1, 1, 'currentuser', 'your business is thrilling')
        self.assertIsInstance(review, Reviews)

    def test_createNewReview(self):        
        final =self.review.createNewReview(1, 1, 1, 'louis', 'review')
        self.assertTrue(final)

    def test_getBusinessReviews(self):
        # result = Reviews(1, 1, 1, 'currentuser', 'your business is thrilling')
        final = self.review.getBizReviews(1)
        self.assertFalse(final)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
def post_rate():
    print(flask_praetorian.current_user().username)
    if flask_praetorian.current_user().username is not None:
        if request.method == 'POST':
            req = request.get_json(force=True)

            col_id = customid()
            username = flask_praetorian.current_user().username
            reviewid = my_random_string(22)
            userid = user_id(username)
            business_id = req.get('businessid', None)
            rating = req.get('rating', None)
            if db.session.query(func.max(Reviews.bid)).scalar() is None:
                bid = 1
            else:
                bid = db.session.query(func.max(Reviews.bid)).scalar() + 1
            text = req.get('review', None)

            # print(f'{rating}, {business_id}, {text}')

            if db.session.query(BusinessDetail).filter(
                    BusinessDetail.business_id == business_id).count() == 0:
                bid = idcounter()
                bizdata = BusinessDetail(bid, business_id)
                db.session.add(bizdata)
                db.session.commit()
            else:
                bizfilter = db.session.query(BusinessDetail).filter(
                    BusinessDetail.business_id == business_id).first()
                bid = bizfilter.b_id

            # userid = uid(username)
            data = Reviews(col_id, reviewid, userid, business_id, rating, text,
                           bid, username)
            db.session.add(data)
            db.session.commit()

            col_id = customid2()
            data1 = YelpReviews(col_id, reviewid, userid, business_id, rating,
                                bid, username)
            db.session.add(data1)
            db.session.commit()

            return {'Status': 'Success'}
    else:
        return {'Status': 'Failed'}
Exemplo n.º 9
0
 def test_reviewInstance(self):
     review = Reviews(1, 1, 1, 'currentuser', 'your business is thrilling')
     self.assertIsInstance(review, Reviews)
Exemplo n.º 10
0
 def setUp(self):
     self.review = Reviews(1, 1, 1, 'currentuser', 'your business is thrilling')