diff --git a/backend/cache.py b/backend/cache.py index b3df9c66..b6d6c99d 100644 --- a/backend/cache.py +++ b/backend/cache.py @@ -56,23 +56,22 @@ def get_plan_file(self, """Return the contents of a plan file from the cache.""" # self._logger.debug(f"get_plan_file({day!r}, {timestamp!r}, {filename!r})") - if newest_before: + if newest_before and not isinstance(timestamp, str): timestamps = self.get_timestamps(day) - if not isinstance(timestamp, str): - timestamps = [t for t in timestamps if t <= timestamp] + timestamps = [t for t in timestamps if t <= timestamp] - for timestamp in timestamps: + for older_timestamp in timestamps: try: - return self.get_plan_file(day, timestamp, filename, newest_before=False) + return self.get_plan_file(day, older_timestamp, filename, newest_before=False) except OSError: pass else: raise FileNotFoundError + else: + path = self.get_plan_path(day, timestamp) / filename - path = self.get_plan_path(day, timestamp) / filename - - with open(path, "r", encoding="utf-8") as f: - return f.read() + with open(path, "r", encoding="utf-8") as f: + return f.read() def store_meta_file(self, content: str, filename: str): """Store a meta file in the cache such as "meta.json".""" diff --git a/backend/meta_extractor.py b/backend/meta_extractor.py index ceea89fa..883a7f86 100644 --- a/backend/meta_extractor.py +++ b/backend/meta_extractor.py @@ -90,9 +90,6 @@ def iterate_daily_extractors(self) -> typing.Generator[DailyMetaExtractor, None, try: plan_kl = self.cache.get_plan_file(day, timestamp, "PlanKl.xml") except FileNotFoundError: - self._logger.warning( - f"Timestamp {timestamp!s} for day {day!s} has no PlanKl.xml file." - ) continue extractor = DailyMetaExtractor(plan_kl) diff --git a/backend/plan_processor.py b/backend/plan_processor.py index 53a0bda5..8f2f4bcd 100644 --- a/backend/plan_processor.py +++ b/backend/plan_processor.py @@ -14,7 +14,7 @@ class PlanProcessor: - VERSION = "74" + VERSION = "75" def __init__(self, cache: Cache, school_number: str, *, logger: logging.Logger): self._logger = logger @@ -67,7 +67,7 @@ def compute_plans(self, date: datetime.date, timestamp: datetime.datetime): self._logger.warning(f"=> Could not find Indiware form plan for date {date!s} and timestamp {timestamp!s}.") else: try: - vplan_kl = self.cache.get_plan_file(date, timestamp, "VPlanKl.xml", newest_before=True) + vplan_kl = self.cache.get_plan_file(date, timestamp, "VplanKl.xml", newest_before=True) except FileNotFoundError: vplan_kl = None plan_extractor = PlanExtractor(plan_kl, vplan_kl, self.teachers.abbreviation_by_surname(), diff --git a/backend/vplan_utils.py b/backend/vplan_utils.py index 82e9557a..555bc95d 100644 --- a/backend/vplan_utils.py +++ b/backend/vplan_utils.py @@ -226,13 +226,16 @@ def periods_to_block_label(periods: list[int]) -> str: def _parse_periods(period_str: str) -> list[int]: + def period_str_to_int(string: str) -> int: + return int(string.replace("Stunde", "").replace(".", "")) + if not period_str: return [] elif "-" not in period_str: - return [int(period_str)] + return [period_str_to_int(period_str)] else: begin, end = period_str.split("-") - return list(range(int(begin), int(end) + 1)) + return list(range(period_str_to_int(begin), period_str_to_int(end) + 1)) def parse_periods(period_str: str) -> list[int]: diff --git a/client/public/base_static/images/school_icons/10000000.png b/client/public/base_static/images/school_icons/10000000.png new file mode 100644 index 00000000..eeb05014 Binary files /dev/null and b/client/public/base_static/images/school_icons/10000000.png differ diff --git a/client/src/App.svelte b/client/src/App.svelte index eab6af9c..5b39e957 100644 --- a/client/src/App.svelte +++ b/client/src/App.svelte @@ -35,7 +35,6 @@ let api_base; let selected_revision; let meta; - let all_meta; let enabled_dates; let grouped_rooms; let course_lists; @@ -62,7 +61,6 @@ api_base = null; selected_revision = ".newest"; meta = {}; - all_meta = {}; enabled_dates = []; grouped_rooms = []; course_lists = {}; @@ -83,8 +81,7 @@ let data = localStorage.getItem(`${school_num}_meta`); if (data !== "undefined" && data) { data = JSON.parse(data); - all_meta = data; - meta = data.meta; + meta = data; all_rooms = data.rooms; teacher_list = Object.keys(data.teachers); grouped_forms = data.forms.grouped_forms; @@ -105,8 +102,7 @@ throw error; } } - all_meta = data; - meta = data.meta; + meta = data; all_rooms = data.rooms; teacher_list = Object.keys(data.teachers); grouped_forms = data.forms.grouped_forms; @@ -284,7 +280,7 @@ $: school_num && (api_base = `/api/v69.420/${school_num}`); $: school_num && reset_plan_vars(); $: school_num && get_meta(); - $: all_revisions = [".newest"].concat((all_meta?.dates || {})[date] || []); + $: all_revisions = [".newest"].concat((meta?.dates || {})[date] || []); $: school_num && get_preferences(); $: all_rooms && (grouped_rooms = group_rooms(all_rooms)); $: $logged_in && get_settings(); @@ -386,7 +382,7 @@ {#if $current_page.substring(0, 4) === "plan"} - + {:else} {/if} diff --git a/client/src/Plan.svelte b/client/src/Plan.svelte index 9d87c109..81c83c56 100644 --- a/client/src/Plan.svelte +++ b/client/src/Plan.svelte @@ -6,13 +6,14 @@ import { swipe } from 'svelte-gestures'; import {preferences, settings, title} from './stores.js'; import {arraysEqual, customFetch, format_date, navigate_page, should_date_be_cached} from "./utils.js"; + import Dropdown from './Components/Dropdown.svelte'; export let api_base; export let school_num; export let date; export let plan_type; export let plan_value; - export let all_meta; + export let meta; export let show_title = true; export let extra_height = true; export let week_letter = ""; @@ -57,10 +58,10 @@ return; } // Check the validity of the plan value - if((plan_type === "rooms" || plan_type === "teachers") && (!Object.keys(all_meta[plan_type]).includes(entity))) { + if((plan_type === "rooms" || plan_type === "teachers") && (!Object.keys(meta[plan_type]).includes(entity))) { reset_plan_vars(); return; - } else if((plan_type === "forms") && !Object.keys(all_meta.forms.forms).includes(entity)) { + } else if((plan_type === "forms") && !Object.keys(meta.forms.forms).includes(entity)) { reset_plan_vars(); return; } @@ -126,6 +127,7 @@ } }); location.hash = gen_location_hash(); + console.log(info); } function periods_to_block_label(periods) { @@ -205,8 +207,8 @@ let full_teacher_name = null; let teacher_contact_link = null; $: if (plan_type === "teachers") { - full_teacher_name = all_meta.teachers[plan_value]?.surname || null; - teacher_contact_link = all_meta.teachers[plan_value]?.contact_link || null; + full_teacher_name = meta.teachers[plan_value]?.surname || null; + teacher_contact_link = meta.teachers[plan_value]?.contact_link || null; } let preferences_apply = true; @@ -316,11 +318,43 @@ {#if info} {#if info.additional_info.length > 0}
- {#each info.additional_info as cur_info} - {#if cur_info !== null} - {cur_info} + {#each info.processed_additional_info as info_paragraph} + {#if info_paragraph.length > 0} +
+ {#each info_paragraph as text_segment} + {#if text_segment.link?.value.length === 1} + + {:else if text_segment.link?.value.length >= 2} +
+ + + + {#each text_segment.link.value as item} + + {/each} + +
+ {:else} + + {/if} + {/each} +
+ {:else} +
{/if} -
{/each}
{/if} @@ -352,6 +386,106 @@