diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2022-02-06 16:55:00 +0000 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2022-02-06 16:55:00 +0000 |
commit | e8285e533c8ed7ff3e68f72b0bbac04b478f19c9 (patch) | |
tree | c4ee6e12a1f543ed03e42516d1dc3497c0fc230d | |
parent | 6f3bca8d3aafe67a5b30a456ab5e80319930e1b6 (diff) | |
download | boymoder.blog-e8285e533c8ed7ff3e68f72b0bbac04b478f19c9.tar.gz boymoder.blog-e8285e533c8ed7ff3e68f72b0bbac04b478f19c9.zip |
added linux ISO CD form
-rw-r--r-- | app.py | 23 | ||||
-rw-r--r-- | database.py | 18 | ||||
-rw-r--r-- | static/index.md | 2 | ||||
-rw-r--r-- | templates/isocd.jinja | 29 | ||||
-rw-r--r-- | templates/isocd_confirmation.jinja | 16 |
5 files changed, 87 insertions, 1 deletions
@@ -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/<zipfile>") 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 %} + <p>As discussed <a href="https://nitter.eda.gay/estrogenizedboy/status/1490322471215636480#m">here</a>, 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:</p> + <form action="/getisocd" method="POST"> + <label for="email">*Email:</label> + <input type="email" id="email" name="email" required><br><br> + <label for="iso">*ISO:</label> + <select name="iso" id="iso" required> + {% for iso in iso_options %} + <option value="{{ iso }}">{{ iso }}</option> + {% endfor %} + </select><br><br> + <label for="name">*Name:</label> + <input id="name" name="name" required><br><br> + <label for="house">*House Number/Name:</label> + <input id="house" name="house" required><br><br> + <label for="street">*Street:</label> + <input id="street" name="street" required><br><br> + <label for="city">City:</label> + <input id="city" name="city"><br><br> + <label for="county">County:</label> + <input id="county" name="county"><br><br> + <label for="postcode">*Postcode:</label> + <input id="postcode" name="postcode" required><br><br> + <input type="submit" value="Submit"> + </form> + <p>I make no promises how long this will actually take, but you might get a special present too uwu</p> + <p>btw if u abuse this service i'll just ignore u</p> +{% 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 %} + <p>Your order has been placed. Expect a confirmation email to {{ email }} when I can be bothered to sort it out.</p> + <br> + <p>Your order/reference id is {{ id_ }}</p> + <br> + <p>The details were as follows:</p> + <table> + {% for k, v in req.items() %} + <tr> + <td>{{ k.upper() }}</td> + <td>{{ v }}</td> + </tr> + {% endfor %} + </table> +{% endblock %}
\ No newline at end of file |