Add country, city and venue.
This commit is contained in:
parent
a0df624f16
commit
301c389ba9
4 changed files with 134 additions and 1 deletions
25
main.py
25
main.py
|
|
@ -101,7 +101,7 @@ def top_events() -> sqlalchemy.orm.query.Query:
|
|||
database.session.query(model.Event.title, func.count())
|
||||
.group_by(model.Event.title)
|
||||
.order_by(func.count().desc())
|
||||
.having(func.count() > 5)
|
||||
.having(func.count() > 3)
|
||||
)
|
||||
return q
|
||||
|
||||
|
|
@ -235,6 +235,29 @@ def top_speakers_page() -> str:
|
|||
return flask.render_template("top_speakers.html", top_speakers=top_speakers())
|
||||
|
||||
|
||||
@app.route("/country")
|
||||
def country_list() -> str:
|
||||
"""Country list."""
|
||||
return flask.render_template("country_list.html", items=model.Country.query)
|
||||
|
||||
|
||||
@app.route("/city/<int:city_id>/venue/new", methods=["GET", "POST"])
|
||||
def add_venue(city_id: int) -> str | Response:
|
||||
"""Add new venue."""
|
||||
city = model.City.query.get(city_id)
|
||||
if flask.request.method != "POST":
|
||||
return flask.render_template("add_venue.html", city=city)
|
||||
|
||||
name = flask.request.form["name"]
|
||||
wikidata_qid = flask.request.form["wikidata_qid"]
|
||||
venue = model.Venue(name=name, city=city, wikidata_qid=wikidata_qid)
|
||||
database.session.add(venue)
|
||||
database.session.commit()
|
||||
|
||||
endpoint = flask.endpoint
|
||||
return flask.redirect(flask.url_for(endpoint))
|
||||
|
||||
|
||||
@app.route("/wikidata")
|
||||
def link_to_wikidata() -> str:
|
||||
items = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue