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,26 +158,43 @@ def get_name_of_lesson_type(lesson_type):
|
||||||
|
|
||||||
|
|
||||||
def generate_lesson_description(lesson, start_datetime, end_datetime, current_day, current_week, overrides={},
|
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
|
# temporarily not supported
|
||||||
#output_settings = {"name": True, "date": True, "teacher": True, "link": True, "comment": True}
|
#output_settings = {"name": True, "date": True, "teacher": True, "link": True, "comment": True}
|
||||||
#output_settings.update(overrides)
|
#output_settings.update(overrides)
|
||||||
|
|
||||||
if lesson.__class__ == dict:
|
if lesson.__class__ == dict:
|
||||||
active_template = load_template(template, "single")
|
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)
|
||||||
|
|
||||||
for i in ['name', 'teacher', 'link']:
|
total_result += load_template(template, "multiple")
|
||||||
active_template = active_template.replace(f"%{i.upper()}%", lesson[i])
|
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']:
|
||||||
|
active_template = active_template.replace(f"%{i.upper()}%", lesson[i])
|
||||||
|
|
||||||
|
|
||||||
human_readable_date = get_human_readable_date(start_datetime, end_datetime,
|
human_readable_date = get_human_readable_date(start_datetime, end_datetime,
|
||||||
current_day, current_week)
|
current_day, current_week)
|
||||||
|
|
||||||
active_template = active_template.replace("%DATE%", human_readable_date)
|
active_template = active_template.replace("%DATE%", human_readable_date)
|
||||||
active_template = active_template.replace("%TYPE%", get_name_of_lesson_type(lesson['type']))
|
active_template = active_template.replace("%TYPE%", get_name_of_lesson_type(lesson['type']))
|
||||||
active_template = active_template.replace("%NAME_PREFIX%", custom_name_prefix)
|
active_template = active_template.replace("%NAME_PREFIX%", custom_name_prefix)
|
||||||
|
|
||||||
return active_template
|
return active_template
|
||||||
|
|
||||||
elif lesson.__class__ == list:
|
elif lesson.__class__ == list:
|
||||||
total_result = load_template(template, "date")
|
total_result = load_template(template, "date")
|
||||||
|
@ -247,14 +264,15 @@ def process_arguments(args, base_day):
|
||||||
|
|
||||||
|
|
||||||
def get_lesson_description(schedule, reference_time, lesson_time, current_day, current_week, overrides={},
|
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_record = schedule[lesson_time]
|
||||||
|
|
||||||
lesson_start_datetime = datetime.fromtimestamp(reference_time + lesson_time)
|
lesson_start_datetime = datetime.fromtimestamp(reference_time + lesson_time)
|
||||||
lesson_end_datetime = datetime.fromtimestamp(reference_time + lesson_time + 5400)
|
lesson_end_datetime = datetime.fromtimestamp(reference_time + lesson_time + 5400)
|
||||||
|
|
||||||
return generate_lesson_description(lesson_record, lesson_start_datetime, lesson_end_datetime, current_day,
|
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):
|
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_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,
|
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]
|
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"
|
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