From e8285e533c8ed7ff3e68f72b0bbac04b478f19c9 Mon Sep 17 00:00:00 2001 From: jwansek Date: Sun, 6 Feb 2022 16:55:00 +0000 Subject: added linux ISO CD form --- app.py | 23 +++++++++++++++++++++++ database.py | 18 +++++++++++++++++- static/index.md | 2 ++ templates/isocd.jinja | 29 +++++++++++++++++++++++++++++ templates/isocd_confirmation.jinja | 16 ++++++++++++++++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 templates/isocd.jinja create mode 100644 templates/isocd_confirmation.jinja diff --git a/app.py b/app.py index 8a38a06..08e45ff 100644 --- a/app.py +++ b/app.py @@ -157,6 +157,15 @@ def serve_nhdl(): **get_template_items("Hentai Downloader", db) ) +@app.route("/isocd") +def serve_iso_form(): + with database.Database() as db: + return flask.render_template( + "isocd.jinja", + **get_template_items("Get a GNU/Linux install CD", db), + iso_options = db.get_iso_cd_options() + ) + @app.route("/zip/") def serve_zip(zipfile): return flask.send_from_directory(os.path.join(".", "static", "zips"), zipfile) @@ -169,6 +178,20 @@ def redirect_nhdl(): except (TypeError, ValueError, KeyError): flask.abort(400) +@app.route("/getisocd", methods = ["POST"]) +def get_iso_cd(): + req = dict(flask.request.form) + print(req) + with database.Database() as db: + id_ = db.append_cd_orders(**req) + print(id_) + return flask.render_template( + "isocd_confirmation.jinja", + **get_template_items("Get a GNU/Linux install CD", db), + email = req["email"], + req = req, + id_ = id_ + ) @app.route("/random") def serve_random(): diff --git a/database.py b/database.py index bb870b8..3dd2d9a 100644 --- a/database.py +++ b/database.py @@ -183,6 +183,21 @@ class Database: cursor.execute("SELECT link FROM headerLinks WHERE name = 'twitter';") return cursor.fetchone()[0] + def get_iso_cd_options(self): + with self.__connection.cursor() as cursor: + cursor.execute("SELECT name FROM isocds;") + return [i[0] for i in cursor.fetchall()] + + def append_cd_orders(self, iso, email, house, street, city, county, postcode, name): + with self.__connection.cursor() as cursor: + cursor.execute(""" + INSERT INTO cd_orders (cd_id, email, house, street, city, county, postcode, name) + VALUES ((SELECT cd_id FROM isocds WHERE name = %s), %s, %s, %s, %s, %s, %s, %s); + """, (iso, email, house, street, city, county, postcode, name)) + id_ = cursor.lastrowid + self.__connection.commit() + return id_ + def update_cache(): # print("updating cache...") with Database() as db: @@ -233,4 +248,5 @@ def request_recent_commits(since = datetime.datetime.now() - datetime.timedelta( if __name__ == "__main__": with Database() as db: - print(db.get_similar_thoughts("about me", 5)) \ No newline at end of file + # print(db.get_similar_thoughts("about me", 5)) + print(db.get_iso_cd_options()) \ No newline at end of file diff --git a/static/index.md b/static/index.md index 58c052c..a644d46 100644 --- a/static/index.md +++ b/static/index.md @@ -4,6 +4,8 @@ i'll post my thoughts on here sometimes, and use this site to link to other stuf [click here for a random image of lio fotia](https://eda.gay/random?tags=lio_fotia) +[click here for a linux ISO CD to be posted to you for free](https://eda.gay/isocd) + ## FOSS alternative services - [nextcloud - dropbox (+ much more!) alternative](https://nc.eda.gay) - [invidious - youtube alternative](https://invidious.eda.gay) diff --git a/templates/isocd.jinja b/templates/isocd.jinja new file mode 100644 index 0000000..915f837 --- /dev/null +++ b/templates/isocd.jinja @@ -0,0 +1,29 @@ +{% extends "template.jinja" %} +{% block content %} +

As discussed here, I will post a GNU/Linux install CD to you for free (provided you live in the United Kingdom). Just fill out the form below:

+
+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +
+

I make no promises how long this will actually take, but you might get a special present too uwu

+

btw if u abuse this service i'll just ignore u

+{% endblock %} \ No newline at end of file diff --git a/templates/isocd_confirmation.jinja b/templates/isocd_confirmation.jinja new file mode 100644 index 0000000..bed09d6 --- /dev/null +++ b/templates/isocd_confirmation.jinja @@ -0,0 +1,16 @@ +{% extends "template.jinja" %} +{% block content %} +

Your order has been placed. Expect a confirmation email to {{ email }} when I can be bothered to sort it out.

+
+

Your order/reference id is {{ id_ }}

+
+

The details were as follows:

+ + {% for k, v in req.items() %} + + + + + {% endfor %} +
{{ k.upper() }}{{ v }}
+{% endblock %} \ No newline at end of file -- cgit v1.2.3