Clean up for Initial Deployment

This commit is contained in:
2026-04-15 11:26:16 -05:00
parent 9797cbc52e
commit 105d897c64
5 changed files with 115 additions and 11 deletions

37
app.py
View File

@@ -121,6 +121,11 @@ def render_main():
) )
@app.route("/help")
def help():
return render_template("help.html")
@app.post("/login") @app.post("/login")
def login(): def login():
username = request.form.get("username") username = request.form.get("username")
@@ -142,6 +147,12 @@ def login():
return redirect(url_for(session.get("main", "index_ade"))) return redirect(url_for(session.get("main", "index_ade")))
@app.route("/logout")
def logout():
session["username"] = None
return redirect(url_for("index_ade"))
@app.route("/register", methods=["GET", "POST"]) @app.route("/register", methods=["GET", "POST"])
def register(): def register():
if request.method == "POST": if request.method == "POST":
@@ -202,10 +213,11 @@ def register():
@app.route("/search") @app.route("/search")
def search(): def search():
stype = request.args.get("search-type") abort(500)
query = request.args.get("search") # stype = request.args.get("search-type")
print(stype, query) # query = request.args.get("search")
return redirect(url_for("index")) # print(stype, query)
# return redirect(url_for("index"))
@app.route("/database", methods=["GET", "POST"]) @app.route("/database", methods=["GET", "POST"])
@@ -224,7 +236,8 @@ def database():
query = json.loads(query) query = json.loads(query)
except: except:
abort(400) abort(400)
results = db[collection].find(query, {"_id": 1, "id": 1}) results = list(db[collection].find(query, {"_id": 1, "id": 1}))
results.append({"_id": "new", "id": "new"})
return render_template( return render_template(
"database.html", cnames=cnames, collection=collection, results=results "database.html", cnames=cnames, collection=collection, results=results
) )
@@ -240,7 +253,9 @@ def database_edit(collection, oid):
if document and "_id" in document: if document and "_id" in document:
del document["_id"] del document["_id"]
try: try:
if not document: if oid == "new":
db[collection].insert_one(document)
elif not document:
db[collection].delete_one({"_id": ObjectId(oid)}) db[collection].delete_one({"_id": ObjectId(oid)})
elif oid: elif oid:
db[collection].replace_one({"_id": ObjectId(oid)}, document) db[collection].replace_one({"_id": ObjectId(oid)}, document)
@@ -249,9 +264,13 @@ def database_edit(collection, oid):
except: except:
abort(500) abort(500)
return redirect(url_for("database")) return redirect(url_for("database"))
result = db[collection].find_one_or_404({"_id": ObjectId(oid)}) if oid == "new":
name = result["id"] name = "New Document"
document = bson.dumps(result, indent=4) document = "{}"
else:
result = db[collection].find_one_or_404({"_id": ObjectId(oid)})
name = result["id"]
document = bson.dumps(result, indent=4)
return render_template( return render_template(
"database_edit.html", "database_edit.html",
collection=collection, collection=collection,

38
static/dialog.css Normal file
View File

@@ -0,0 +1,38 @@
main {
display: flex;
flex-direction: row;
gap: 0.5em;
margin: 2em;
>div {
border: 1px solid var(--color);
background-color: var(--color-bg2);
flex-grow: 1;
}
}
p {
margin: 0.25em;
}
#login {
flex-grow: 0;
min-width: 15em;
>form {
display: flex;
flex-direction: column;
margin: 0 0.25em 0.25em 0.25em;
gap: 0.25em;
label {
margin-bottom: -0.5em;
}
}
}
@media (max-width: 750px) {
main {
flex-direction: column;
}
}

View File

@@ -182,6 +182,10 @@ header {
transform: scale(1.005); transform: scale(1.005);
} }
#news {
display: none;
}
@media (max-width: 750px) { @media (max-width: 750px) {
header { header {
height: fit-content; height: fit-content;

View File

@@ -24,8 +24,11 @@
<div id="header-top"> <div id="header-top">
<div> <div>
<span class="spacer"></span> <span class="spacer"></span>
<a href="/account">Account</a> <a href="/help">Help</a>
<a>Console</a> <a href="/ade">Frontpage</a>
{% if session["username"] %}
<a href="/logout">Log Out</a>
{% endif %}
</div> </div>
</div> </div>
<div id="header-bottom"> <div id="header-bottom">

40
templates/help.html Normal file
View File

@@ -0,0 +1,40 @@
{% extends "base.html" %}
{% block head %}
<link rel="stylesheet" href="{{ url_for('static', filename='dialog.css') }}">
{% endblock %}
{% block content %}
<main>
<div>
<h2>Index Help Page</h2>
<h3>Welcome to the Icolotl Index!</h3>
<p>This website contains various projects, all under the Icolotl umbrella or one of our sub-sectors. Most of
these do require log-in, so if you're visiting the Index as a guest there might not be much for you here. If
you've forgotten your password or are missing authorizations, please contact one of our admins at their
email below. Thanks!</p>
<ul>
<li><a href="mailto:adeline@icolotl.com">Adeline &lt;adeline@icolotl.com&gt; (System Operator)</a></li>
<li><a href="mailto:despoina@icolotl.com">Despoina &lt;despoina@icolotl.com&gt; (Touchstone Admin)</a></li>
<li><a href="mailto:camilla@icolotl.com">Camilla &lt;camilla@icolotl.com&gt; (Lab Engineer)</a></li>
<li><a href="mailto:beatrice@icolotl.com">Beatrice &lt;beatrice@icolotl.com&gt; (Maintenance)</a></li>
<li><a href="mailto:morgana@icolotl.com">Morgana &lt;morgana@icolotl.com&gt; (Editor)</a></li>
</ul>
</div>
<div id="login">
<h2>Index Unified Login</h2>
<form method="post" action="{{ url_for('login') }}">
{% if session["username"] %}
<span>Welcome, <b>{{ session["username"] }}</b>.</span>
<input type="submit" value="Log Out">
{% else %}
<label for="username">Username:</label>
<input id="username" name="username" autocomplete="username">
<label for="password">Password:</label>
<input type="password" id="password" name="password" autocomplete="current-password">
<input type="submit" value="Log In">
{% endif %}
</form>
</div>
</main>
{% endblock %}