diff options
Diffstat (limited to 'uploader/species/views.py')
-rw-r--r-- | uploader/species/views.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/uploader/species/views.py b/uploader/species/views.py index f39ca98..10715a5 100644 --- a/uploader/species/views.py +++ b/uploader/species/views.py @@ -8,26 +8,33 @@ from flask import (flash, current_app as app) from uploader.population import popbp -from uploader.datautils import order_by_family +from uploader.platforms import platformsbp from uploader.ui import make_template_renderer from uploader.db_utils import database_connection from uploader.oauth2.client import oauth2_get, oauth2_post from uploader.authorisation import require_login, require_token +from uploader.datautils import order_by_family, enumerate_sequence -from .models import all_species, save_species, species_by_id, species_families +from .models import (all_species, + save_species, + species_by_id, + update_species, + species_families) speciesbp = Blueprint("species", __name__) speciesbp.register_blueprint(popbp, url_prefix="/") +speciesbp.register_blueprint(platformsbp, url_prefix="/") render_template = make_template_renderer("species") @speciesbp.route("/", methods=["GET"]) +@require_login def list_species(): """List and display all the species in the database.""" with database_connection(app.config["SQL_URI"]) as conn: return render_template("species/list-species.html", - allspecies=all_species(conn)) + allspecies=enumerate_sequence(all_species(conn))) @speciesbp.route("/<int:species_id>", methods=["GET"]) @require_login @@ -177,9 +184,14 @@ def edit_species_extra(token: dict, species_id: int):# pylint: disable=[unused-a ).either(__failure__, lambda res: res) if bool(species) and request.method == "POST": - flash("We would have edited the species, but the feature is not " - "currently implemented …", - "alert-danger") + update_species(conn, + species_id, + request.form["species_name"], + request.form["species_fullname"], + request.form["species_family"], + int(request.form["species_familyorderid"]), + int(request.form["species_orderid"])) + flash("Updated species successfully.", "alert-success") return redirect(url_for("species.edit_species_extra", species_id=species_id)) |