diff --git a/app.py b/app.py index 041ef87..6a3a71c 100755 --- a/app.py +++ b/app.py @@ -484,6 +484,10 @@ def get_other(entity): return get_labels(other_items) +@app.route("/admin/edits") +def list_edits(): + return render_template('list_edits.html', edits=Edit.query) + @app.route("/next/Q") def next_page(item_id): qid = f'Q{item_id}' diff --git a/depicts/model.py b/depicts/model.py index 5007504..6912cfa 100644 --- a/depicts/model.py +++ b/depicts/model.py @@ -5,6 +5,7 @@ from sqlalchemy.types import Integer, String, DateTime from sqlalchemy.orm import column_property, relationship from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.sql.expression import cast +from urllib.parse import quote Base = declarative_base() Base.query = session.query_property() @@ -40,3 +41,11 @@ class Edit(Base): painting_id = Column(Integer, primary_key=True) depicts_id = Column(Integer, primary_key=True) timestamp = Column(DateTime, default=now_utc()) + + painting_qid = column_property('Q' + cast(painting_id, String)) + depicts_qid = column_property('Q' + cast(depicts_id, String)) + + @property + def user_page_url(self): + start = 'https://www.wikidata.org/wiki/User:' + return start + quote(self.username.replace(' ', '_')) diff --git a/templates/list_edits.html b/templates/list_edits.html new file mode 100644 index 0000000..355f0d5 --- /dev/null +++ b/templates/list_edits.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} + +{% block content %} +
+ +

This tool has been used to save {{ edits.count() }} edits.

+ + + + + + + + + + + {% for edit in edits %} + + + + + + + {% endfor %} + +
usernamepaintingdepicts
{{ edit.username }}{{ edit.painting_qid }}{{ edit.depicts_qid }}{{ edit.timestamp }}
+ + +
+ +{% endblock %}