mirror of
https://github.com/13hannes11/ics-proxy.git
synced 2024-09-06 08:01:41 +02:00
add editing functionality to index page
This commit is contained in:
40
src/main.rs
40
src/main.rs
@@ -196,14 +196,38 @@ async fn index_process(
|
||||
}
|
||||
}
|
||||
} else if query.get("edit").is_some() {
|
||||
let uuid = Uuid::nil();
|
||||
// TODO: add actuall logic and use proper uuid
|
||||
redirect_to_edit_page(
|
||||
tmpl,
|
||||
"Entry found in database!".to_string(),
|
||||
uuid,
|
||||
REDIRECT_TIMEOUT_S,
|
||||
)
|
||||
match query.get("link") {
|
||||
Some(link) => {
|
||||
// Splitting string and getting uuid, alternatively pretend whole string is uuid
|
||||
let vec: Vec<&str> = link.split("/").collect();
|
||||
|
||||
let mut uuid_str = link.to_string();
|
||||
if vec.len() > 1 {
|
||||
uuid_str = match vec.get(vec.len() - 2) {
|
||||
Some(s) => s.to_string(),
|
||||
None => link.to_string(),
|
||||
};
|
||||
}
|
||||
|
||||
match Uuid::parse_str(&uuid_str) {
|
||||
Ok(uuid) => redirect_to_edit_page(
|
||||
tmpl,
|
||||
"Got uuid from submission!".to_string(),
|
||||
uuid,
|
||||
REDIRECT_TIMEOUT_S,
|
||||
),
|
||||
// TODO: actually redirect back to index page
|
||||
Err(e) => error_page(tmpl, format!("could not parse uuid: {}", e.to_string())),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
// TODO: actually redirect back to index page
|
||||
error_page(
|
||||
tmpl,
|
||||
"link attribute not set please enter a link".to_string(),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error_page(tmpl, "missing create or edit form submission!".to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user