diff options
Diffstat (limited to 'webapp.py')
-rw-r--r-- | webapp.py | 58 |
1 files changed, 53 insertions, 5 deletions
@@ -104,9 +104,9 @@ footer { </li> </ul> </section> - {%- if builds -%} - <section> - <h3>Cross builds</h3> + <section> + <h3>Cross builds</h3> + {%- if builds -%} <table> <thead> <tr> @@ -134,8 +134,21 @@ footer { {%- endfor -%} </tbody> </table> - </section> - {%- endif -%} + {%- else -%} + <p>No build performed yet.</p> + {%- endif -%} + <form method="POST" action="{{ url_for("request_schedule")|e }}"> + <input type="submit" name="schedule" value="cross build" /> + {{ sourcepackage|e }} for + <input type="hidden" name="source" value="{{ sourcepackage|e }}" /> + <select name="architecture"> + <option value="any">any</option> + {%- for architecture in architectures -%} + <option value="{{ architecture|e }}">{{ architecture|e }}</option> + {%- endfor -%} + </select> + </form> + </section> <footer> <h3>Details about this service</h3> <ul> @@ -147,6 +160,18 @@ footer { </html> """ +schedule_template = """<!DOCTYPE html> +<html> + <body> + <p>Scheduled a build of {{ request.form["source"]|e }} + {%- if request.form["architecture"] != "any" %} + for {{ request.form["architecture"]|e -}} + {%- endif %}. + <p> + </body> +</html> +""" + @app.template_filter("sqltimestamp") def sqltimestamp_filter(s): strptime = datetime.datetime.strptime @@ -228,3 +253,26 @@ def show_log(filename): mimetype="text/plain") except FileNotFoundError: raise werkzeug.exceptions.NotFound() + + +@app.route("/schedule", methods=["POST"]) +def request_schedule(): + source = flask.request.form["source"] + architecture = flask.request.form["architecture"] + with db.engine.connect() as conn: + query = sqlalchemy.text(""" + SELECT 1 FROM depstate WHERE source = :source;""") + if not conn.execute(query, source=source).first(): + raise werkzeug.exceptions.BadRequest() + if architecture == "any": + architecture = None + else: + query = sqlalchemy.text(""" + SELECT 1 FROM depcheck WHERE architecture = :architecture;""") + if not conn.execute(query, architecture=architecture).first(): + raise werkzeug.exceptions.BadRequest() + query = sqlalchemy.text(""" + INSERT INTO buildrequests (source, architecture, requesttime) + VALUES (:source, :architecture, datetime('now'));""") + conn.execute(query, source=source, architecture=architecture) + return flask.render_template_string(schedule_template) |