aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uploader/oauth2/client.py2
-rw-r--r--uploader/session.py2
-rw-r--r--uploader/species/models.py28
-rw-r--r--uploader/templates/populations/view-population.html3
4 files changed, 20 insertions, 15 deletions
diff --git a/uploader/oauth2/client.py b/uploader/oauth2/client.py
index e119cc3..70a32ff 100644
--- a/uploader/oauth2/client.py
+++ b/uploader/oauth2/client.py
@@ -61,7 +61,7 @@ def __update_auth_server_jwks__(jwks) -> KeySet:
def auth_server_jwks() -> KeySet:
"""Fetch the auth-server JSON Web Keys information."""
- _jwks = session.session_info().get("auth_server_jwks")
+ _jwks = session.session_info().get("auth_server_jwks") or {}
if bool(_jwks):
return __update_auth_server_jwks__({
"last-updated": _jwks["last-updated"],
diff --git a/uploader/session.py b/uploader/session.py
index 399f28c..b538187 100644
--- a/uploader/session.py
+++ b/uploader/session.py
@@ -96,7 +96,7 @@ def user_token() -> Either:
def set_auth_server_jwks(keyset: KeySet) -> KeySet:
"""Update the JSON Web Keys in the session."""
save_session_info({
- **session_info(),
+ **session_info(),# type: ignore[misc]
"auth_server_jwks": {
"last-updated": datetime.now().timestamp(),
"jwks": keyset.as_dict()
diff --git a/uploader/species/models.py b/uploader/species/models.py
index 1abed6d..51f941c 100644
--- a/uploader/species/models.py
+++ b/uploader/species/models.py
@@ -28,7 +28,7 @@ def order_species_by_family(species: tuple[dict, ...]) -> list:
**ordered,
_key: ordered.get(_key, tuple()) + (current,)
}
- ordered = reduce(__order__, species, {})
+ ordered = reduce(__order__, species, {})# type: ignore[var-annotated]
return sorted(tuple(ordered.items()), key=lambda item: item[0][0])
@@ -47,7 +47,7 @@ def save_species(conn: mdb.Connection,
common_name: str,
scientific_name: str,
family: str,
- taxon_id: Optional[str] = None) -> int:
+ taxon_id: Optional[str] = None) -> dict:
"""
Save a new species to the database.
@@ -58,14 +58,14 @@ def save_species(conn: mdb.Connection,
common_name: The species' common name.
scientific_name; The species' scientific name.
"""
- genus, species = scientific_name.split(" ")
+ genus, species_name = scientific_name.split(" ")
families = species_families(conn)
with conn.cursor() as cursor:
cursor.execute("SELECT MAX(OrderId) FROM Species")
species = {
"common_name": common_name,
"common_name_lower": common_name.lower(),
- "menu_name": f"{common_name} ({genus[0]}. {species.lower()})",
+ "menu_name": f"{common_name} ({genus[0]}. {species_name.lower()})",
"scientific_name": scientific_name,
"family": family,
"family_order": families[family],
@@ -91,13 +91,15 @@ def save_species(conn: mdb.Connection,
}
-def update_species(conn: mdb.Connection,
- species_id: int,
- common_name: str,
- scientific_name: str,
- family: str,
- family_order: int,
- species_order: int):
+def update_species(# pylint: disable=[too-many-arguments]
+ conn: mdb.Connection,
+ species_id: int,
+ common_name: str,
+ scientific_name: str,
+ family: str,
+ family_order: int,
+ species_order: int
+):
"""Update a species' details.
Parameters
@@ -114,12 +116,12 @@ def update_species(conn: mdb.Connection,
species_order: The ordering of this species in relation to others
"""
with conn.cursor(cursorclass=DictCursor) as cursor:
- genus, species = scientific_name.split(" ")
+ genus, species_name = scientific_name.split(" ")
species = {
"species_id": species_id,
"common_name": common_name,
"common_name_lower": common_name.lower(),
- "menu_name": f"{common_name} ({genus[0]}. {species.lower()})",
+ "menu_name": f"{common_name} ({genus[0]}. {species_name.lower()})",
"scientific_name": scientific_name,
"family": family,
"family_order": family_order,
diff --git a/uploader/templates/populations/view-population.html b/uploader/templates/populations/view-population.html
index 31db54f..319addc 100644
--- a/uploader/templates/populations/view-population.html
+++ b/uploader/templates/populations/view-population.html
@@ -23,6 +23,9 @@
{%block contents%}
<div class="row">
<h2>Population Details</h2>
+
+ {{flash_all_messages()}}
+
<dl>
<dt>Name</dt>
<dd>{{population.Name}}</dd>