can no longer have duplicate species in db, added non-functional registration page, updated styling #53

Merged
TussockyJoker merged 3 commits from TussockyJoker/Komodo-Hub:main into main 2026-03-05 22:03:20 +00:00
11 changed files with 63 additions and 33 deletions

No files matched your search

View File
Whitespace-only changes.
+15 -22
View File
@@ -4,19 +4,22 @@ from database.db_connection import get_db
def add_species(english, latin, body, category, extinction_risk, image_id):
with get_db() as conn:
conn.execute("""
INSERT INTO species (
species_english,
species_latin,
body_text,
category,
extinction_risk,
created_at,
photoid
try:
conn.execute("""
INSERT INTO species (
species_english,
species_latin,
body_text,
category,
extinction_risk,
created_at,
photoid
)
VALUES (?, ?, ?, ?, ?, ?, ?)
""", (english, latin.lower(), body, category, extinction_risk, datetime.now(), image_id))
)
VALUES (?, ?, ?, ?, ?, ?, ?)
""", (english.title(), latin.lower(), body, category, extinction_risk, datetime.now(), image_id))
except:
raise ValueError("This species already exists in the database, would you like to edit it?")
def get_all_species():
@@ -48,16 +51,6 @@ WHERE
).fetchall()
return [dict(row) for row in rows]
def get_species_by_name(species_english):
with get_db() as conn:
row = conn.execute(
"SELECT * FROM species WHERE species_english = ?",
(species_english,)
).fetchone()
return dict(row) if row else None
def delete_species(species_id):
with get_db() as conn:
conn.execute(
+1 -1
View File
@@ -97,7 +97,7 @@ def init_database():
conn.execute("""
CREATE TABLE IF NOT EXISTS species (
species_id INTEGER PRIMARY KEY AUTOINCREMENT,
species_english TEXT,
species_english TEXT UNIQUE,
species_latin TEXT,
body_text TEXT,
category TEXT,
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
from flask import render_template, Blueprint, request, redirect, url_for
page = Blueprint("login", __name__, url_prefix="")
@page.route("/login")
def login():
return render_template("accounts/login.jinja")
@page.route("/register")
def register():
return render_template("accounts/user_registration.jinja")
-7
View File
@@ -1,7 +0,0 @@
from flask import render_template, Blueprint, request, redirect, url_for
page = Blueprint("login", __name__, url_prefix="")
@page.route("/login")
def portal():
return render_template("accounts/login.jinja")
+3 -1
View File
@@ -14,7 +14,7 @@ def portal():
@page.route("/", methods=["POST"])
def add_species_to_database():
try:
eng_name = request.form["eng_name"].capitalize()
eng_name = request.form["eng_name"].title()
latin_name = request.form["latin_name"].capitalize()
main_text = request.form["main_text"]
category = request.form["category"].capitalize()
@@ -36,6 +36,8 @@ def add_species_to_database():
"species_portal/species_portal_failed.jinja",
error_information=error_information
)
# now add editing functionality
@page.route("/delete/<species_english>", methods=["POST"])
Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 44 KiB

+1 -1
View File
@@ -147,7 +147,7 @@ h6 {
font-size: 1.5rem;
font-weight: 700;
color: var(--text);
margin-left: 1rem;
text-align: center;
}
.navbar .links {
+1 -1
View File
@@ -1,6 +1,6 @@
{# needs to redirect if user logged in #}
{% extends "base.jinja" %}
{% block title %} Species Upload Portal {% endblock %}
{% block title %} Log In {% endblock %}
{% block head %}
{% endblock %}
{% block content %}
@@ -0,0 +1,31 @@
{# needs to redirect if user logged in #}
{% extends "base.jinja" %}
{% block title %} Register {% endblock %}
{% block head %}
{% endblock %}
{% block content %}
{% from 'button.jinja' import button %}
<section id="hero" class="form">
<form action="" class="container" method="POST">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="text" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
</div>
<div class="form-group">
<label for="password_confirm">Confirm Password:</label>
<input type="password" id="password_confirm" name="password_confirm">
</div>
<button type="submit" class="submit-button">
Login
</button>
</form>
</section>
{% endblock %}