Skip to content

Commit

Permalink
Merge pull request #193 from ArtrenH/main
Browse files Browse the repository at this point in the history
27.09.2023 21:05
  • Loading branch information
OfficialFreak authored Sep 27, 2023
2 parents efb1448 + cfcf3e1 commit c8bdc00
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 209 deletions.
14 changes: 7 additions & 7 deletions backend/lesson_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def resolve_teacher_abbreviations(surnames: list[str], abbreviation_by_surname:


def __parse_message(info: str, lesson: models.Lesson) -> tuple[ParsedLessonInfoMessage, re.Match | None]:
if match := _InfoParsers.substitution.search(info):
if match := _InfoParsers.substitution.match(info):
return InsteadOfCourse(
plan_type="forms",
plan_value=lesson.forms,
Expand All @@ -426,21 +426,21 @@ def __parse_message(info: str, lesson: models.Lesson) -> tuple[ParsedLessonInfoM
periods=lesson.periods,
_teachers=set(match.group("teachers").split(",")),
), match
elif match := _InfoParsers.moved_from.search(info):
elif match := _InfoParsers.moved_from.match(info):
return MovedFrom(
plan_type="forms",
plan_value=lesson.forms,
periods=[int(match.group("period_begin"))],
date=None
), match
elif match := _InfoParsers.instead_of.search(info):
elif match := _InfoParsers.instead_of.match(info):
return MovedFrom(
plan_type="forms",
plan_value=lesson.forms,
periods=parse_periods(match.group("periods")),
date=datetime.datetime.strptime(f'{match.group("date")}{lesson._lesson_date.year}', "%d.%m.%Y").date()
), match
elif match := _InfoParsers.held_at.search(info):
elif match := _InfoParsers.held_at.match(info):
return MovedTo(
plan_type="forms",
plan_value=lesson.forms,
Expand All @@ -450,7 +450,7 @@ def __parse_message(info: str, lesson: models.Lesson) -> tuple[ParsedLessonInfoM
date=datetime.datetime.strptime(f'{match.group("date")}{lesson._lesson_date.year}', "%d.%m.%Y").date(),
periods=parse_periods(match.group("periods"))
), match
elif match := _InfoParsers.moved_to.search(info):
elif match := _InfoParsers.moved_to.match(info):
return MovedTo(
plan_type="forms",
plan_value=lesson.forms,
Expand All @@ -460,7 +460,7 @@ def __parse_message(info: str, lesson: models.Lesson) -> tuple[ParsedLessonInfoM
date=None,
periods=parse_periods(match.group("periods")),
), match
elif match := _InfoParsers.moved_to_date.search(info):
elif match := _InfoParsers.moved_to_date.match(info):
return MovedTo(
plan_type="forms",
plan_value=lesson.forms,
Expand All @@ -470,7 +470,7 @@ def __parse_message(info: str, lesson: models.Lesson) -> tuple[ParsedLessonInfoM
date=datetime.datetime.strptime(f'{match.group("date")}{lesson._lesson_date.year}', "%d.%m.%Y").date(),
periods=parse_periods(match.group("periods")),
), match
elif match := _InfoParsers.cancelled.search(info):
elif match := _InfoParsers.cancelled.match(info):
return Cancelled(
plan_type="forms",
plan_value=lesson.forms,
Expand Down
2 changes: 1 addition & 1 deletion backend/plan_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class PlanProcessor:
VERSION = "82"
VERSION = "83"

def __init__(self, cache: Cache, school_number: str, *, logger: logging.Logger):
self._logger = logger
Expand Down
27 changes: 7 additions & 20 deletions client/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import Settings from "./Settings.svelte";
import AboutUs from "./AboutUs.svelte";
import SveltyPicker from 'svelty-picker';
import {get_settings, group_rooms, update_colors, navigate_page, init_indexed_db} from "./utils.js";
import {get_settings, group_rooms, update_colors, navigate_page, init_indexed_db, clear_plan_cache} from "./utils.js";
import {notifications} from './notifications.js';
import {logged_in, title, current_page, preferences, settings, active_modal, pwa_prompt, indexed_db} from './stores.js'
import {customFetch, format_revision_date} from "./utils.js";
Expand Down Expand Up @@ -262,23 +262,7 @@
function logout() {
close_modal();
localStorage.clear();
try {
console.log("Trying to close DB");
$indexed_db.close();
console.log("Trying to delete DB");
var req = indexedDB.deleteDatabase('plan-db');
req.onsuccess = function () {
console.log("Deleted database successfully");
};
req.onerror = function () {
console.log("Couldn't delete database");
};
req.onblocked = function () {
console.log("Couldn't delete database due to the operation being blocked");
};
} catch (ex) {
console.log("Failed deleting DB", ex);
}
clear_plan_cache();
localStorage.setItem('logged_in', `${$logged_in}`);
init_vars();
Expand All @@ -292,9 +276,11 @@
function refresh_plan_vars() {
let tmp_variables = location.hash.split("|");
if (tmp_variables.length === 5) {
if (tmp_variables.length >= 3) {
school_num = decodeURI(tmp_variables[1]);
date = decodeURI(tmp_variables[2]);
}
if (tmp_variables.length === 5) {
plan_type = decodeURI(tmp_variables[3]);
plan_value = decodeURI(tmp_variables[4]);
}
Expand Down Expand Up @@ -451,6 +437,7 @@
#page-container {
position: relative;
min-height: calc(100vh - 56px);
padding-bottom: 15px;
@media only screen and (min-width: 602px) {
min-height: calc(100vh - 64px);
Expand Down Expand Up @@ -492,7 +479,7 @@
:global(.responsive-heading) {
font-size: var(--font-size-xl);
margin-bottom: 15px;
line-height: 1.6;
line-height: 1.2;
font-weight: 700;
}
Expand Down
11 changes: 7 additions & 4 deletions client/src/Authentication.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<label for="l_password">Passwort</label>
<div class="input_icon password_field">
<img src="/public/base_static/images/lock-solid.svg" alt="Lock Icon">
<button type="button" on:click={() => {login_password_visible = !login_password_visible}}>
<button type="button" on:click={() => {login_password_visible = !login_password_visible}} tabindex="-1">
<span class="material-symbols-outlined">{login_password_visible ? "visibility_off" : "visibility"}</span>
</button>
<input disabled={register_visible} autocomplete="current-password" name="l_password" on:input={(event) => {l_password = event.target.value}} type={login_password_visible ? "text" : "password"} minlength="1" required class="textfield" placeholder="Passwort"/>
Expand All @@ -91,7 +91,9 @@
{/if}
{#if register_visible}
<form on:submit|preventDefault={signup} transition:fly|local={{x:500}}>
<button on:click={toggle_form} type="reset" id="back_button">←</button>
<button on:click={toggle_form} type="reset" id="back_button">
<span class="material-symbols-outlined">keyboard_backspace</span>
</button>
<h1 class="responsive-heading">Registrieren</h1>
<label for="s_nickname">Nutzername</label>
<div class="input_icon">
Expand All @@ -101,7 +103,7 @@
<label for="s_nickname">Passwort</label>
<div class="input_icon password_field">
<img src="/public/base_static/images/lock-solid.svg" alt="Lock Icon">
<button type="button" on:click={() => {register_password_visible = !register_password_visible}}>
<button type="button" on:click={() => {register_password_visible = !register_password_visible}} tabindex="-1">
<span class="material-symbols-outlined">{register_password_visible ? "visibility_off" : "visibility"}</span>
</button>
<input disabled={!register_visible} autocomplete="new-password" name="s_password" on:input={(event) => {s_password = event.target.value}} type={register_password_visible ? "text" : "password"} minlength="10" required class="textfield" placeholder="Passwort"/>
Expand Down Expand Up @@ -256,8 +258,9 @@
#back_button {
position: absolute;
top: 0px;
top: 5px;
left: 5px;
padding: 0;
border: 0;
background: none;
color: white;
Expand Down
1 change: 1 addition & 0 deletions client/src/Components/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
margin: 3px;
font-size: var(--font-size-base);
position: relative;
hyphens: auto;
.material-symbols-outlined {
font-size: 1.3em;
Expand Down
84 changes: 65 additions & 19 deletions client/src/Lesson.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,28 @@
</div>
{/if}
<!-- Rooms -->
<div class="rooms vert-align max-width-center info-element" class:changed={room_changed} class:changed_filled_in={$settings.filled_in_buttons && room_changed}>
{#if rooms.length !== 0 || s_rooms.length !== 0}
{#each rooms || [] as room}
<button on:click={() => {
plan_type = "rooms";
plan_value = room;
}}>{room}</button>
{#if plan_type !== "rooms"}
<div class="rooms vert-align max-width-center info-element" class:changed={room_changed} class:changed_filled_in={$settings.filled_in_buttons && room_changed}>
{#if rooms.length !== 0 || s_rooms.length !== 0}
{#each rooms || [] as room}
<button on:click={() => {
plan_type = "rooms";
plan_value = room;
}}>{room}</button>
{:else}
<span class="extra_padding">-</span>
{/each}
{#each s_rooms || [] as room}
<button on:click={() => {
plan_type = "rooms";
plan_value = room;
}}><s>{room}</s></button>
{/each}
{:else}
<span class="extra_padding">-</span>
{/each}
{#each s_rooms || [] as room}
<button on:click={() => {
plan_type = "rooms";
plan_value = room;
}}><s>{room}</s></button>
{/each}
{:else}
<span class="extra_padding">-</span>
{/if}
</div>
{/if}
</div>
{/if}
<!-- Forms -->
{#if plan_type !== "forms"}
{#if forms.length === 0 && s_forms.length !== 0}
Expand Down Expand Up @@ -159,7 +161,7 @@
{/if}
</div>
<!-- Additional Infos -->
{#if (lesson.info.length > 0) || (plan_type === "forms" && (forms.length > 1))}
{#if (lesson.info.length > 0) || (plan_type === "forms" && (forms.length > 1)) || (plan_type === "teachers" && (teachers.length > 1)) || (plan_type === "rooms" && (rooms.length > 1))}
<div class="info-element lesson-info">
<ul>
{#each lesson.info as info_paragraph}
Expand Down Expand Up @@ -222,6 +224,50 @@
</div>
</li>
{/if}
{#if plan_type === "teachers" && (teachers.length > 1)}
<li>
<div class="horizontal_wrapper">
Beteiligte Lehrer:
<div class="fit-content-width">
<Dropdown let:toggle small={true} transform_origin_x="50%">
<button slot="toggle_button" on:click={toggle} class="toggle-button">
<span class="grow">{teachers.join(', ')}</span>
<span class="material-symbols-outlined dropdown-arrow">arrow_drop_down</span>
</button>
{#each teachers as teacher}
<button on:click={() => {
plan_type = "teachers";
plan_value = teacher;
}}>{teacher}</button>
{/each}
</Dropdown>
</div>
</div>
</li>
{/if}
{#if plan_type === "rooms" && (rooms.length > 1)}
<li>
<div class="horizontal_wrapper">
In Räumen:
<div class="fit-content-width">
<Dropdown let:toggle small={true} transform_origin_x="50%">
<button slot="toggle_button" on:click={toggle} class="toggle-button">
<span class="grow">{rooms.join(', ')}</span>
<span class="material-symbols-outlined dropdown-arrow">arrow_drop_down</span>
</button>
{#each rooms as room}
<button on:click={() => {
plan_type = "rooms";
plan_value = room;
}}>{room}</button>
{/each}
</Dropdown>
</div>
</div>
</li>
{/if}
</ul>
</div>
{/if}
Expand Down
Loading

0 comments on commit c8bdc00

Please sign in to comment.