diff --git a/templates/isa.html b/templates/isa.html new file mode 100644 index 0000000..758ce76 --- /dev/null +++ b/templates/isa.html @@ -0,0 +1,87 @@ +{% extends "base.html" %} + +{% block title %}{{ item.label() }} ({{ item.qid }}) {% endblock %} + +{% block content %} +
+ +

{{ self.title() }}

+ +
+ view on Wikidata + +
+ +
+
+ + +
+
+ + {% set description = item.description() %} + {% set aliases = item.get_aliases() %} + {% set osm_tag_list = item.get_claim("P1282") %} + +
+ {% if description %} + description: + {{ description }}
+ {% endif %} + + {% if aliases %} + aliases: + {{ aliases | join("; ") }} + {% endif %} +
+ +

subclass of

+
+ {% if subclass_list %} + {% for subclass in subclass_list %} + {{ subclass.label }} + ({{ subclass.qid }}) + – {{ subclass.description }} +
+ {% endfor %} + {% else %} +

no subclasses

+ {% endif %} +
+ +

OpenStreetMap tags/keys from Wikidata

+ {% if osm_tag_list %} + + {% else %} +

no tags/keys from Wikidata

+ {% endif %} + +

extra OpenStreetMap tags/keys

+ + {% if extra %} + + {% else %} +

no extra tags/keys

+ {% endif %} + +
+
+
+ +
+
+
+ +
+
+ +
+{% endblock %} diff --git a/web_view.py b/web_view.py index a47335b..d7a3192 100755 --- a/web_view.py +++ b/web_view.py @@ -128,6 +128,44 @@ def redirect_from_root(): def index_page(): return render_template("index.html") + +def get_username(): + user = flask_login.current_user + if user.is_authenticated: + return user.username + + +@app.route("/isa/Q", methods=["GET", "POST"]) +def isa_page(item_id): + item = api.get_item(item_id) + + if request.method == "POST": + return redirect(url_for(request.endpoint, item_id=item_id)) + + q = model.ItemExtraKeys.query.filter_by(item=item) + extra = [e.tag_or_key for e in q] + subclass_property = "P279" + + subclass_list = [] + for s in item.get_claim(subclass_property): + subclass = api.get_item(s["numeric-id"]) + subclass_list.append({ + "qid": s["id"], + "item_id": s["numeric-id"], + "label": subclass.label(), + "description": subclass.description(), + "isa_page_url": url_for("isa_page", item_id=s["numeric-id"]), + }) + + return render_template( + "isa.html", + item=item, + extra=extra, + subclass_list=subclass_list, + username=get_username() + ) + + @app.route("/admin/skip_isa") def admin_skip_isa_list(): q = model.Item.query.join(model.SkipIsA).order_by(model.Item.item_id) @@ -254,8 +292,8 @@ def map_location(zoom, lat, lon): zoom=zoom, lat=lat, lon=lon, - radius=request.args.get('radius'), - username=username, + radius=request.args.get("radius"), + username=get_username(), mode="map", q=None, )