Merge pull request 'changed 'species.db' to 'database.db', created non-functional login page, removed unnecessary code' (#51) from TussockyJoker/Komodo-Hub:main into main

Reviewed-on: #51
This commit was merged in pull request #51.
This commit is contained in:
TussockyJoker committed 2026-03-03 23:08:49 +00:00
commit 0859a1bec7
9 files changed
+35 -54

No files matched your search

+1
View File
@@ -218,3 +218,4 @@ database/species.db
static/images/.DS_Store
.DS_Store
database/database.db
+1 -1
View File
@@ -1,4 +1,4 @@
[homepage]
[featured_species]
species1 = Sumatran Tiger
species2 = Javan Rhinoceros
species3 = Bali Myna
+1 -1
View File
@@ -1,7 +1,7 @@
import sqlite3
from contextlib import contextmanager
DATABASE_PATH = "database/species.db"
DATABASE_PATH = "database/database.db"
@contextmanager
def get_db():
+7
View File
@@ -0,0 +1,7 @@
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")
-2
View File
@@ -2,8 +2,6 @@ from flask import render_template, Blueprint
import configparser
from utilities.featured_species import featured_species_function
# config = configparser.ConfigParser()
page = Blueprint("home", __name__, url_prefix="/")
+23
View File
@@ -0,0 +1,23 @@
{# needs to redirect if user logged in #}
{% extends "base.jinja" %}
{% block title %} Species Upload Portal {% 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="password">Password:</label>
<input type="password" id="password" name="password">
</div>
<button type="submit" class="submit-button">
Login
</button>
</form>
</section>
{% endblock %}
+1 -3
View File
@@ -14,9 +14,7 @@ Species Database
{# If you want to change the featured species please do so in config.ini - CS #}
{{featured_species_section(featured_species, False)}}
{# All Species #}
<div>
{{search_bar("/species/search")}}
</div>
{{search_bar("/species/search")}}
<h2 style="text-align: center; margin-top: 30px;">All Species</h2>
{{display_all_items(species)}}
{% endblock %}
-46
View File
@@ -1,46 +0,0 @@
import sqlite3
from datetime import datetime
# from main import database as db
def add_species(english, latin, body):
db = sqlite3.connect("database/species.db", check_same_thread=False)
db.execute(
"""
CREATE TABLE IF NOT EXISTS species (
species_id INTEGER PRIMARY KEY AUTOINCREMENT,
species_english TEXT,
species_latin TEXT,
body_text TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
"""
)
db.commit()
print("Database initialized.")
cursor = db.cursor()
cursor.execute(
"""
INSERT INTO species (
species_english,
species_latin,
body_text,
created_at
)
VALUES (?, ?, ?, ?)
""",
(english, latin, body, datetime.now()),
)
db.commit()
db.close()
print("Species added successfully.")
+1 -1
View File
@@ -5,7 +5,7 @@ from database.db_commands import get_species_by_name
def featured_species_function(config_file):
config = configparser.ConfigParser()
config.read(config_file)
featured_species_list = list(dict(config["homepage"]).values())
featured_species_list = list(dict(config["featured_species"]).values())
featured_species = []
for species in featured_species_list:
featured_species.append(get_species_by_name(species))