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(
|
.service(
|
||||||
web::scope("/download")
|
web::scope("/download")
|
||||||
.route("/png/{redirect_id}", web::get().to(views::download_png)),
|
.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/"))
|
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 {
|
div.actions {
|
||||||
width: 400px;
|
margin-left:5px;
|
||||||
height: 400px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
width:100%;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 30px;
|
padding: 10px;
|
||||||
color: #333;
|
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;
|
display:block;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -15,6 +15,12 @@
|
|||||||
<label for="code">Code:</label>
|
<label for="code">Code:</label>
|
||||||
<input type="text" name="code" value="{{link.code}}">
|
<input type="text" name="code" value="{{link.code}}">
|
||||||
</div>
|
</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>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user