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