Skip to content

Commit

Permalink
feat: contact field on school add
Browse files Browse the repository at this point in the history
(cherry picked from commit c935f45)
  • Loading branch information
OfficialFreak authored and Belissimo-T committed Sep 13, 2024
1 parent 394d3da commit a5a96f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/src/components/SchoolManager.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
let password_visible = false;
let school_add_visible = false;
let contact = "";
let add_school_name = "";
let add_school_num = "";
let add_school_username = "";
Expand Down Expand Up @@ -151,17 +152,18 @@
function add_school() {
let formData = new FormData();
formData.append('contact', contact);
formData.append('display_name', add_school_name);
formData.append('school_num', add_school_num);
formData.append('username', add_school_username);
formData.append('pw', add_school_password);
let tmp_api_base = `/api/v69.420/${authorize_school_id}`;
customFetch(`/api/v69.420/add_school`, {
method: 'POST',
body: formData
})
.then(data => {
notifications.success(data);
contact = "";
school_add_visible = false;
add_school_name = "";
add_school_num = "";
Expand Down Expand Up @@ -258,6 +260,8 @@
<span class="material-symbols-outlined">keyboard_backspace</span>
</button>
<h1 class="responsive-heading">Schule hinzufügen</h1>
<label for="contact">Deine Kontaktdaten (Discord/E-Mail/Telefon)</label>
<input disabled={!school_add_visible} name="contact" bind:value={contact} type="text" required class="textfield" placeholder="max.musterman"/>
<label for="add_school_name">Name der Schule</label>
<input disabled={!school_add_visible} autocomplete="organization" name="add_school_name" bind:value={add_school_name} type="text" required class="textfield" placeholder="Name der Schule (z.B. Max-Mustermann-Gymnasium Löbau)"/>
<label for="add_school_num">Schulnummer</label>
Expand Down
5 changes: 5 additions & 0 deletions endpoints/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ def contact() -> Response:
@login_required
def add_school() -> Response:
data = request.form
contact = data.get("contact")
if contact is None:
return send_error("Keine Kontaktmöglichkeit angegeben")
school_num = data.get("school_num")
if school_num is None:
return send_error("Keine Schulnummer angegeben")
Expand All @@ -506,6 +509,8 @@ def add_school() -> Response:

candidate = SchoolCandidate("", school_num, username, pw)
embed = BetterEmbed(title="Neue Schulanfrage!", color="ffffff", inline=False)
embed.add_embed_field("Nickname des users:", f"{current_user.get_field('nickname')}", inline=False)
embed.add_embed_field("Kontakt:", contact, inline=False)
embed.add_embed_field("Schulnummer:", school_num, inline=False)
embed.add_embed_field("Schulname:", display_name, inline=False)
embed.add_embed_field("Nutzername:", username, inline=False)
Expand Down

0 comments on commit a5a96f3

Please sign in to comment.