Add page to list edits.
This commit is contained in:
parent
39d2760ab9
commit
68cf86162b
4
app.py
4
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<int:item_id>")
|
||||
def next_page(item_id):
|
||||
qid = f'Q{item_id}'
|
||||
|
|
|
@ -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(' ', '_'))
|
||||
|
|
31
templates/list_edits.html
Normal file
31
templates/list_edits.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="p-2">
|
||||
|
||||
<p>This tool has been used to save {{ edits.count() }} edits.</p>
|
||||
|
||||
<table class="table w-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>username</th>
|
||||
<th>painting</th>
|
||||
<th>depicts</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for edit in edits %}
|
||||
<tr>
|
||||
<td><a href="{{ edit.user_page_url }}">{{ edit.username }}</a></td>
|
||||
<td>{{ edit.painting_qid }}</td>
|
||||
<td>{{ edit.depicts_qid }}</td>
|
||||
<td>{{ edit.timestamp }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in a new issue