forked from Ugric/Komodo-Hub
added delete button to species_editor, updated styling
This commit is contained in:
1 parent
781e38ab49
commit
1c2575091e
4 files changed
+34
-22
No files matched your search
@@ -1,6 +1,5 @@
|
||||
from flask import render_template, Blueprint, request, redirect, url_for
|
||||
from database.db_commands import delete_species, get_species_by_id, update_species
|
||||
import os
|
||||
import uuid
|
||||
|
||||
page = Blueprint("species_editor", __name__, url_prefix="/species/editor")
|
||||
@@ -47,4 +46,18 @@ def edit_success(eng_name):
|
||||
return render_template(
|
||||
"species_portal/species_portal_success.jinja",
|
||||
eng_name = eng_name,
|
||||
)
|
||||
)
|
||||
|
||||
@page.route("/delete/<species_english>", methods=["POST"])
|
||||
def delete_species_from_database(species_english):
|
||||
try:
|
||||
entry = get_species_by_name(species_english)
|
||||
if entry is None:
|
||||
raise ValueError(f"Species '{species_english}' not found.")
|
||||
delete_species(entry["species_id"])
|
||||
return redirect(url_for("species.all_species"))
|
||||
except Exception as error_information:
|
||||
return render_template(
|
||||
"species_portal/species_portal_failed.jinja",
|
||||
error_information=error_information
|
||||
)
|
||||
@@ -46,19 +46,4 @@ def portal_success(eng_name):
|
||||
return render_template(
|
||||
"species_portal/species_portal_success.jinja",
|
||||
eng_name = eng_name,
|
||||
)
|
||||
|
||||
|
||||
@page.route("/delete/<species_english>", methods=["POST"])
|
||||
def delete_species_from_database(species_english):
|
||||
try:
|
||||
entry = get_species_by_name(species_english)
|
||||
if entry is None:
|
||||
raise ValueError(f"Species '{species_english}' not found.")
|
||||
delete_species(entry["species_id"])
|
||||
return redirect(url_for("species.all_species"))
|
||||
except Exception as error_information:
|
||||
return render_template(
|
||||
"species_portal/species_portal_failed.jinja",
|
||||
error_information=error_information
|
||||
)
|
||||
)
|
||||
+14
-2
@@ -611,7 +611,7 @@ input:focus {
|
||||
border-radius: 20px;
|
||||
border: 2px solid var(--primary);
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
||||
margin: 1rem auto;
|
||||
margin: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@@ -721,7 +721,6 @@ input:focus {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* Submit button */
|
||||
.submit-button {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
@@ -735,6 +734,19 @@ input:focus {
|
||||
transition: 0.2s ease;
|
||||
}
|
||||
|
||||
.delete-button {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
border-radius: 14px;
|
||||
border: none;
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
background: linear-gradient(120deg, rgb(255, 0, 0), rgb(255, 0, 0), rgb(255, 0, 0));
|
||||
color: rgb(255, 255, 255);
|
||||
transition: 0.2s ease;
|
||||
}
|
||||
|
||||
.submit-button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 20px rgba(0,0,0,0.25);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% from 'button.jinja' import button %}
|
||||
<h1>SPECIES EDITOR</h1>
|
||||
<h1 style="text-align: center;">SPECIES EDITOR</h1>
|
||||
<section id="hero" class="form">
|
||||
<form action="{{ url_for('species_editor.species_update', species_id=species_id) }}" class="container" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@@ -50,7 +50,9 @@
|
||||
<button type="submit" class="submit-button">
|
||||
Update Species Information
|
||||
</button>
|
||||
|
||||
<form action="{{ url_for('species_editor.delete_species_from_database', species_english=sp['species_english']) }}" method="POST" class="container" style="text-align: center;">
|
||||
<button type="submit" class="delete-button">Delete from Database</button>
|
||||
</form>
|
||||
</form>
|
||||
<div class="container" style="height: fit-content; width:fit-content; text-align:center; max-width: 40%">
|
||||
<p> Current photo: </p>
|
||||
|
||||
Reference in new issue
Block a user