Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
3
Indexable
Never
def fill_list_lesson(
    qs_point_sorted, count_lesson,
    count_lesson_point, count_buy
):
    list_lesson = []
    for pos, lesson in enumerate(range(count_lesson)):
        data_lesson = {}
        if pos < count_lesson_point:
            point_obj = qs_point_sorted[pos]
            if point_obj.get('is_passed') == True:
                data_lesson["status"] = "green"
                degree = pgettext_lazy('degree', 'ДЗ 1/1 - выполнено')
            elif point_obj.get('is_no_home_task') == True:
                data_lesson["status"] = "blue"
                degree = pgettext_lazy('degree', 'Нет ДЗ - за')
            else:
                data_lesson["status"] = "red"
                degree = pgettext_lazy('degree', 'ДЗ 0/1 - не выполнено')

            data_lesson["info"] = {
                'id_lesson': point_obj.get('id_lesson'),
                'topic': point_obj.get('topic'),
                'date': point_obj.get('date'),
                'time': point_obj.get('time'),
                'degree': degree,
            }
        elif pos < count_buy:
            data_lesson["status"] = "grey"
        else:
            data_lesson["status"] = "blank"
        list_lesson.append(data_lesson)
    return list_lesson