Clean up for Initial Deployment
This commit is contained in:
31
app.py
31
app.py
@@ -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,6 +264,10 @@ def database_edit(collection, oid):
|
|||||||
except:
|
except:
|
||||||
abort(500)
|
abort(500)
|
||||||
return redirect(url_for("database"))
|
return redirect(url_for("database"))
|
||||||
|
if oid == "new":
|
||||||
|
name = "New Document"
|
||||||
|
document = "{}"
|
||||||
|
else:
|
||||||
result = db[collection].find_one_or_404({"_id": ObjectId(oid)})
|
result = db[collection].find_one_or_404({"_id": ObjectId(oid)})
|
||||||
name = result["id"]
|
name = result["id"]
|
||||||
document = bson.dumps(result, indent=4)
|
document = bson.dumps(result, indent=4)
|
||||||
|
|||||||
38
static/dialog.css
Normal file
38
static/dialog.css
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
40
templates/help.html
Normal 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 <adeline@icolotl.com> (System Operator)</a></li>
|
||||||
|
<li><a href="mailto:despoina@icolotl.com">Despoina <despoina@icolotl.com> (Touchstone Admin)</a></li>
|
||||||
|
<li><a href="mailto:camilla@icolotl.com">Camilla <camilla@icolotl.com> (Lab Engineer)</a></li>
|
||||||
|
<li><a href="mailto:beatrice@icolotl.com">Beatrice <beatrice@icolotl.com> (Maintenance)</a></li>
|
||||||
|
<li><a href="mailto:morgana@icolotl.com">Morgana <morgana@icolotl.com> (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 %}
|
||||||
Reference in New Issue
Block a user