mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
Fix restoring for group calendars
This commit is contained in:
@@ -53,11 +53,27 @@ li.collection-list-item {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<h1>Welcome {{ user_id }}!</h1>
|
||||
<h1>Welcome {{ user.id }}!</h1>
|
||||
<form method="POST" action="/frontend/logout">
|
||||
<button type="submit">Log out</button>
|
||||
</form>
|
||||
|
||||
<h2>Profile</h2>
|
||||
|
||||
<h3>App tokens</h3>
|
||||
|
||||
<ul>
|
||||
{% for app_token in user.app_tokens %}
|
||||
<li>
|
||||
{{ app_token.name }}
|
||||
{% if let Some(created_at) = app_token.created_at %}
|
||||
{{ created_at.to_rfc3339() }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Calendars</h2>
|
||||
<ul>
|
||||
{% for calendar in calendars %}
|
||||
@@ -89,7 +105,7 @@ li.collection-list-item {
|
||||
<span class="description">
|
||||
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
||||
</span>
|
||||
<form action="/frontend/user/{{ user_id }}/calendar/{{ calendar.id}}/restore" method="POST" class="restore-form">
|
||||
<form action="/frontend/user/{{ calendar.principal }}/calendar/{{ calendar.id}}/restore" method="POST" class="restore-form">
|
||||
<button type="submit">Restore</button>
|
||||
</form>
|
||||
<div class="color-chip"></div>
|
||||
@@ -124,7 +140,7 @@ li.collection-list-item {
|
||||
<span class="description">
|
||||
{% if let Some(description) = addressbook.description %}{{ description }}{% endif %}
|
||||
</span>
|
||||
<form action="/frontend/user/{{ user_id }}/addressbook/{{ addressbook.id}}/restore" method="POST" class="restore-form">
|
||||
<form action="/frontend/user/{{ addressbook.principal }}/addressbook/{{ addressbook.id}}/restore" method="POST" class="restore-form">
|
||||
<button type="submit">Restore</button>
|
||||
</form>
|
||||
</a>
|
||||
|
||||
@@ -34,7 +34,7 @@ pub use config::FrontendConfig;
|
||||
#[derive(Template, WebTemplate)]
|
||||
#[template(path = "pages/user.html")]
|
||||
struct UserPage {
|
||||
pub user_id: String,
|
||||
pub user: User,
|
||||
pub calendars: Vec<Calendar>,
|
||||
pub deleted_calendars: Vec<Calendar>,
|
||||
pub addressbooks: Vec<Addressbook>,
|
||||
@@ -53,19 +53,33 @@ async fn route_user<CS: CalendarStore, AS: AddressbookStore>(
|
||||
if user_id != user.id {
|
||||
return actix_web::HttpResponse::Unauthorized().body("Unauthorized");
|
||||
}
|
||||
dbg!(&user);
|
||||
|
||||
let mut calendars = vec![];
|
||||
for group in user.memberships() {
|
||||
calendars.extend(cal_store.get_calendars(group).await.unwrap());
|
||||
}
|
||||
|
||||
let mut deleted_calendars = vec![];
|
||||
for group in user.memberships() {
|
||||
deleted_calendars.extend(cal_store.get_deleted_calendars(group).await.unwrap());
|
||||
}
|
||||
|
||||
let mut addressbooks = vec![];
|
||||
for group in user.memberships() {
|
||||
addressbooks.extend(addr_store.get_addressbooks(group).await.unwrap());
|
||||
}
|
||||
|
||||
let mut deleted_addressbooks = vec![];
|
||||
for group in user.memberships() {
|
||||
deleted_addressbooks.extend(addr_store.get_deleted_addressbooks(group).await.unwrap());
|
||||
}
|
||||
|
||||
UserPage {
|
||||
calendars,
|
||||
deleted_calendars: cal_store.get_deleted_calendars(&user.id).await.unwrap(),
|
||||
addressbooks: addr_store.get_addressbooks(&user.id).await.unwrap(),
|
||||
deleted_addressbooks: addr_store.get_deleted_addressbooks(&user.id).await.unwrap(),
|
||||
user_id: user.id,
|
||||
deleted_calendars,
|
||||
addressbooks,
|
||||
deleted_addressbooks,
|
||||
user: user,
|
||||
}
|
||||
.respond_to(&req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user