Redirects: properly redirect to the current week

Previously, most redirects targeted the root of the application.
This was okay for the first part of development where only one week would be
active, but would be annoying when using multiple weeks.

Change those redirects to call week::week.

Change the login path to be dependant on the current week as well,
so it can be correctly redirected.
This commit is contained in:
trotFunky 2024-07-26 01:08:30 +01:00
parent e08a46af3a
commit a0b79a17ea
6 changed files with 22 additions and 22 deletions

View file

@ -10,7 +10,7 @@ use rocket::serde::json::Json;
use rocket_db_pools::{sqlx, Connection};
use crate::{auth, database};
use crate::{auth, database, week};
use crate::database_records::{Vote, VotingData};
#[derive(FromForm)]
@ -25,7 +25,7 @@ pub async fn vote(week: u8, form: Form<VoteForm>,
if !user.logged_in {
cookies.add(("toast_error", "Vous n'avez pas la permission de changer de vote."));
return Redirect::to(uri!("/"));
return Redirect::to(uri!(week::week(week)));
}
let filtered_votes = form.truth_votes.iter().filter_map(
@ -85,7 +85,7 @@ pub async fn vote(week: u8, form: Form<VoteForm>,
debug!("Vote successful")
}
Redirect::to(uri!("/"))
Redirect::to(uri!(week::week(week)))
}
#[derive(Serialize, Deserialize)]