working better, small changes
This commit is contained in:
@@ -62,7 +62,10 @@ pub struct Row {
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct CalendarPage {
|
||||
pub lang: String,
|
||||
/// `true` only on the admin dashboard — enables the editable cells.
|
||||
pub is_admin: bool,
|
||||
/// `true` whenever the admin is signed in — controls the nav links.
|
||||
pub logged_in: bool,
|
||||
pub base_path: String,
|
||||
pub has_courts: bool,
|
||||
pub courts: Vec<CourtOpt>,
|
||||
@@ -102,6 +105,7 @@ pub async fn build_calendar(
|
||||
ctx: &AppContext,
|
||||
lang: &str,
|
||||
is_admin: bool,
|
||||
logged_in: bool,
|
||||
q_court: Option<i32>,
|
||||
q_week: Option<String>,
|
||||
) -> Result<CalendarPage> {
|
||||
@@ -191,6 +195,7 @@ pub async fn build_calendar(
|
||||
Ok(CalendarPage {
|
||||
lang: lang.to_string(),
|
||||
is_admin,
|
||||
logged_in,
|
||||
base_path: if is_admin { "/admin" } else { "/" }.to_string(),
|
||||
has_courts: !courts_opts.is_empty(),
|
||||
courts: courts_opts,
|
||||
@@ -216,7 +221,12 @@ pub async fn index(
|
||||
Query(q): Query<CalQuery>,
|
||||
) -> Result<Response> {
|
||||
let lang = current_lang(&jar);
|
||||
let page = build_calendar(&ctx, &lang, false, q.court, q.week).await?;
|
||||
// The public calendar is read-only for everyone, admin included. When an
|
||||
// admin is signed in we still flag it so the nav keeps the admin links.
|
||||
let logged_in = crate::controllers::admin::current_admin(&ctx, &jar)
|
||||
.await
|
||||
.is_some();
|
||||
let page = build_calendar(&ctx, &lang, false, logged_in, q.court, q.week).await?;
|
||||
format::render().view(&v, "calendar/week.html", &page)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user