auto-schedule-pro-v2: in schedule lookup set date to be always on top even if the lesson is single
This commit is contained in:
parent
e57773ccbb
commit
d6bd061090
|
@ -158,12 +158,29 @@ def get_name_of_lesson_type(lesson_type):
|
|||
|
||||
|
||||
def generate_lesson_description(lesson, start_datetime, end_datetime, current_day, current_week, overrides={},
|
||||
custom_name_prefix="Назва", template="legacy-vibrant"):
|
||||
custom_name_prefix="Назва", template="legacy-vibrant", force_date_at_top=False):
|
||||
# temporarily not supported
|
||||
#output_settings = {"name": True, "date": True, "teacher": True, "link": True, "comment": True}
|
||||
#output_settings.update(overrides)
|
||||
|
||||
if lesson.__class__ == dict:
|
||||
if force_date_at_top:
|
||||
total_result = load_template(template, "date")
|
||||
human_readable_date = get_human_readable_date(start_datetime, end_datetime,
|
||||
current_day, current_week)
|
||||
total_result = total_result.replace("%DATE%", human_readable_date)
|
||||
|
||||
total_result += load_template(template, "multiple")
|
||||
for i in ['name', 'teacher', 'link']:
|
||||
total_result = total_result.replace(f"%{i.upper()}%", lesson[i])
|
||||
|
||||
total_result = total_result.replace("%DATE%", human_readable_date)
|
||||
total_result = total_result.replace("%TYPE%", get_name_of_lesson_type(lesson['type']))
|
||||
total_result = total_result.replace("%NAME_PREFIX%", custom_name_prefix)
|
||||
|
||||
return total_result + "\n"
|
||||
|
||||
else:
|
||||
active_template = load_template(template, "single")
|
||||
|
||||
for i in ['name', 'teacher', 'link']:
|
||||
|
@ -247,14 +264,15 @@ def process_arguments(args, base_day):
|
|||
|
||||
|
||||
def get_lesson_description(schedule, reference_time, lesson_time, current_day, current_week, overrides={},
|
||||
custom_name_prefix="Назва", template="legacy-vibrant"):
|
||||
custom_name_prefix="Назва", template="legacy-vibrant", force_date_at_top=False):
|
||||
lesson_record = schedule[lesson_time]
|
||||
|
||||
lesson_start_datetime = datetime.fromtimestamp(reference_time + lesson_time)
|
||||
lesson_end_datetime = datetime.fromtimestamp(reference_time + lesson_time + 5400)
|
||||
|
||||
return generate_lesson_description(lesson_record, lesson_start_datetime, lesson_end_datetime, current_day,
|
||||
current_week, overrides=overrides, custom_name_prefix=custom_name_prefix, template=template)
|
||||
current_week, overrides=overrides, custom_name_prefix=custom_name_prefix, template=template,
|
||||
force_date_at_top=force_date_at_top)
|
||||
|
||||
|
||||
def process(message, path):
|
||||
|
@ -325,7 +343,7 @@ def process(message, path):
|
|||
lesson_list = [i for i in schedule if selected_day * 86400 <= i < (selected_day + 1) * 86400]
|
||||
|
||||
lesson_descriptions_list = [get_lesson_description(schedule, reference_time, lesson_time, current_day,
|
||||
current_week, overrides=preferences, custom_name_prefix="Назва", template=output_style_preference)
|
||||
current_week, overrides=preferences, custom_name_prefix="Назва", template=output_style_preference, force_date_at_top=True)
|
||||
for lesson_time in lesson_list]
|
||||
|
||||
return f"<b><u>Пари у {WEEKDAYS_ACCUSATIVE[selected_day % 7]}</u></b>:\n\n\n" + "\n".join(lesson_descriptions_list), "HTML"
|
||||
|
|
|
@ -1 +1 @@
|
|||
<b><u>%DATE%</u></b>:
|
||||
<u>%DATE%</u>:
|
||||
|
|
Loading…
Reference in New Issue