예제 #1
0
    def to_json(self):
        json_answers = []
        for answer in self.answers:
            json_answers.append(answer.to_json())

        checker = MealChecker()
        return {
            'meal': self.get_meal(),
            'date': str(self.date),
            'answers': json_answers
        }
예제 #2
0
def index():
    current_time = datetime.datetime.now()
    meal = MealChecker.check_meal(current_time)

    if meal is None:
        return render_template('closed.html')

    dict = {1: "Cafe da manha", 2: "Almoco", 3: "Jantar"}
    meal_label = dict[meal]

    return render_template('index.html', meal_label=meal_label)
예제 #3
0
파일: app.py 프로젝트: alisonbnt/enquete-ru
def index():
    current_time = datetime.datetime.now()
    meal = MealChecker.check_meal(current_time)

    if meal is None:
        return render_template('closed.html')

    dict = {
        1: "Cafe da manha",
        2: "Almoco",
        3: "Jantar"
    }
    meal_label = dict[meal]

    return render_template('index.html', meal_label=meal_label)
예제 #4
0
파일: app.py 프로젝트: alisonbnt/enquete-ru
def results():
    current_date = datetime.datetime.now()
    meal = MealChecker.check_meal(current_date)

    if meal is None:
        return render_template('closed.html')

    start_date = datetime.datetime(current_date.year, current_date.month, current_date.day)
    enquete = Enquete.query.find_by_meal(start_date, meal)

    if enquete is None:
        return render_template('empty.html')


    data = {}
    data.update({"count": len(enquete.answers)})
    likes = {
        "loved": 0,
        "liked": 0,
        "neutral": 0,
        "disliked": 0,
        "hated": 0
    }
    comments = []
    for answer in enquete.answers:
        if answer.like_level == 0:
            likes['hated'] += 1

        if answer.like_level == 1:
            likes['disliked'] += 1

        if answer.like_level == 2:
            likes['neutral'] += 1

        if answer.like_level == 3:
            likes['liked'] += 1

        if answer.like_level == 4:
            likes['loved'] += 1

        comments.append(answer.comment)

    data.update({"comments": comments})
    data.update({"likes": likes})

    return render_template('results.html', data=data)
예제 #5
0
def results():
    current_date = datetime.datetime.now()
    meal = MealChecker.check_meal(current_date)

    if meal is None:
        return render_template('closed.html')

    start_date = datetime.datetime(current_date.year, current_date.month,
                                   current_date.day)
    enquete = Enquete.query.find_by_meal(start_date, meal)

    if enquete is None:
        return render_template('empty.html')

    data = {}
    data.update({"count": len(enquete.answers)})
    likes = {"loved": 0, "liked": 0, "neutral": 0, "disliked": 0, "hated": 0}
    comments = []
    for answer in enquete.answers:
        if answer.like_level == 0:
            likes['hated'] += 1

        if answer.like_level == 1:
            likes['disliked'] += 1

        if answer.like_level == 2:
            likes['neutral'] += 1

        if answer.like_level == 3:
            likes['liked'] += 1

        if answer.like_level == 4:
            likes['loved'] += 1

        comments.append(answer.comment)

    data.update({"comments": comments})
    data.update({"likes": likes})

    return render_template('results.html', data=data)
예제 #6
0
 def get_meal(self):
     print("Chamando do objeto")
     meal = MealChecker.check_meal(self.date)
     print(meal)
     return meal
예제 #7
0
 def get_meal(self):
     print("Chamando do objeto")
     meal = MealChecker.check_meal(self.date)
     print(meal)
     return meal