parent
d451a4f05c
commit
5d28707e18
@ -151,6 +151,12 @@ async fn main() -> std::io::Result<()> {
|
||||
),
|
||||
),
|
||||
)
|
||||
.service(
|
||||
web::scope("/delete").service(
|
||||
web::scope("/link")
|
||||
.route("/{redirect_id}", web::get().to(views::process_link_delete)),
|
||||
),
|
||||
)
|
||||
.service(
|
||||
web::scope("/download")
|
||||
.route("/png/{redirect_id}", web::get().to(views::download_png)),
|
||||
|
13
src/views.rs
13
src/views.rs
@ -446,3 +446,16 @@ pub(crate) async fn process_link_edit(
|
||||
}
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
|
||||
pub(crate) async fn process_link_delete(
|
||||
id: Identity,
|
||||
link_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
if let Some(_id) = id.identity() {
|
||||
use super::schema::links::dsl::{code, links};
|
||||
let connection = establish_connection()?;
|
||||
diesel::delete(links.filter(code.eq(&link_id.0))).execute(&connection)?;
|
||||
return Ok(redirect_builder("/admin/index/"));
|
||||
}
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
|
@ -66,17 +66,28 @@ svg {
|
||||
}
|
||||
|
||||
div.actions {
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
margin-left:5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width:100%;
|
||||
align-items: center;
|
||||
padding: 30px;
|
||||
padding: 10px;
|
||||
color: #333;
|
||||
flex-flow: row wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
a.button {
|
||||
div.danger {
|
||||
background-color: rgb(235, 127, 77);
|
||||
font-size: smaller;
|
||||
border: 2px solid crimson;
|
||||
}
|
||||
|
||||
div.danger h3 {
|
||||
width:100%;
|
||||
}
|
||||
|
||||
a.button, div.actions input {
|
||||
width: 150px;
|
||||
display:block;
|
||||
padding: 15px;
|
||||
text-align: center;
|
||||
|
@ -15,6 +15,12 @@
|
||||
<label for="code">Code:</label>
|
||||
<input type="text" name="code" value="{{link.code}}">
|
||||
</div>
|
||||
<input type="submit" value="Speichern">
|
||||
<div class="actions danger">
|
||||
<h2>Achtung!</h2>
|
||||
<h3>Werden schon veröffentlichte Links gelöscht oder editiert sind die Links z.B. aus einem Buch
|
||||
nicht mehr gültig! UNBEDINGT VERMEIDEN!</h3>
|
||||
<input type="submit" value="Speichern">
|
||||
<a class="button" href="/admin/delete/link/{{link.code}}">Delete</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user