From 82b91506b0645b59a8423e37b400fe5211a02563 Mon Sep 17 00:00:00 2001 From: Brieuc Dubois <git@bhasher.com> Date: Fri, 24 May 2024 12:28:15 +0200 Subject: [PATCH] Allow anyone to create or book a session --- backend/app/main.py | 18 +++++++++--------- frontend/src/lang/fr.json | 2 +- frontend/src/routes/+page.svelte | 26 ++++++++++++-------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index 4bee061d..a26e955f 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -382,10 +382,10 @@ def create_session( db: Session = Depends(get_db), current_user: schemas.User = Depends(get_jwt_user), ): - if not check_user_level(current_user, models.UserType.TUTOR): - raise HTTPException( - status_code=401, detail="You do not have permission to create a session" - ) + # if not check_user_level(current_user, models.UserType.TUTOR): + # raise HTTPException( + # status_code=401, detail="You do not have permission to create a session" + # ) return crud.create_session(db, current_user) @@ -453,11 +453,11 @@ def add_user_to_session( db: Session = Depends(get_db), current_user: schemas.User = Depends(get_jwt_user), ): - if not check_user_level(current_user, models.UserType.TUTOR): - raise HTTPException( - status_code=401, - detail="You do not have permission to add a user to a session", - ) + # if not check_user_level(current_user, models.UserType.TUTOR): + # raise HTTPException( + # status_code=401, + # detail="You do not have permission to add a user to a session", + # ) db_session = crud.get_session(db, session_id) if db_session is None: diff --git a/frontend/src/lang/fr.json b/frontend/src/lang/fr.json index 6638cf46..3c84c434 100644 --- a/frontend/src/lang/fr.json +++ b/frontend/src/lang/fr.json @@ -23,7 +23,7 @@ "actions": "Actions", "add": "Ajouter", "deleteSessionConfirm": "Êtes-vous sûr de vouloir supprimer cette session ? Cette action est irréversible.", - "createSession": "Nouvelle session", + "createSession": "Session immédiate", "participantPlaceholder": "Choisir", "remainingDuration": "Temps restant", "nickname": "Nom", diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index d7eb1fff..5e591d7e 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -106,20 +106,18 @@ <div class="flex-grow flex-col flex"> {#if contact} <div class="p-4 pr-8"> - {#if $user?.is_tutor || $user?.is_admin} - <button on:click|preventDefault={createSession} class="button float-end"> - {$t('home.createSession')} - </button> - {:else} - <a - class="button float-end" - class:btn-disabled={!contact || !contact.calcom_link} - href={contact.calcom_link} - target="_blank" - > - {$t('home.bookSession')} - </a> - {/if} + <button on:click|preventDefault={createSession} class="button float-end"> + {$t('home.createSession')} + </button> + <div class="size-4 float-end"></div> + <a + class="button float-end" + class:btn-disabled={!contact || !contact.calcom_link} + href={contact.calcom_link} + target="_blank" + > + {$t('home.bookSession')} + </a> </div> <div class="flex-grow p-2"> <h2 class="text-xl my-4 font-bold">{$t('home.currentSessions')}</h2> -- GitLab