add: user associations

This commit is contained in:
trisua 2025-06-05 20:56:56 -04:00
parent 50319f9124
commit 675b3e4ee6
11 changed files with 131 additions and 9 deletions

View file

@ -180,9 +180,25 @@ pub async fn manage_profile_request(
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
};
let associations = {
let mut out = Vec::new();
for id in &profile.associated {
out.push(match data.0.get_user_by_id(id.to_owned()).await {
Ok(ua) => ua,
// TODO: remove from associated on error
Err(_) => continue,
});
}
out
};
let lang = get_lang!(jar, data.0);
let mut context = initial_context(&data.0.0, lang, &Some(user)).await;
context.insert("profile", &profile);
context.insert("associations", &associations);
// return
Ok(Html(data.1.render("mod/profile.html", &context).unwrap()))