aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-06-30 20:30:51 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-06-30 20:31:00 -0700
commiteb9c5b9a8d0b55e0ddaec864a1810f5f5d963a3e (patch)
tree6154a519565d2b94fae54f32d9ea20088be4785c /python/fatcat
parent9f40f6131cb08f14a8a5b4211af9c71ee474f3e6 (diff)
downloadfatcat-eb9c5b9a8d0b55e0ddaec864a1810f5f5d963a3e.tar.gz
fatcat-eb9c5b9a8d0b55e0ddaec864a1810f5f5d963a3e.zip
more fatcat-web views (changelog, history, etc)
Diffstat (limited to 'python/fatcat')
-rw-r--r--python/fatcat/routes.py162
-rw-r--r--python/fatcat/templates/changelog.html23
-rw-r--r--python/fatcat/templates/changelog_view.html13
-rw-r--r--python/fatcat/templates/container_create.html (renamed from python/fatcat/templates/container_add.html)0
-rw-r--r--python/fatcat/templates/editgroup_view.html50
-rw-r--r--python/fatcat/templates/editor_changelog.html10
-rw-r--r--python/fatcat/templates/editor_view.html6
-rw-r--r--python/fatcat/templates/entity_edit.html8
-rw-r--r--python/fatcat/templates/entity_history.html30
-rw-r--r--python/fatcat/templates/home.html6
-rw-r--r--python/fatcat/templates/release_create.html (renamed from python/fatcat/templates/work_add.html)0
11 files changed, 262 insertions, 46 deletions
diff --git a/python/fatcat/routes.py b/python/fatcat/routes.py
index 5bd68ba1..ec6b849e 100644
--- a/python/fatcat/routes.py
+++ b/python/fatcat/routes.py
@@ -18,9 +18,43 @@ def container_view(ident):
abort(ae.status)
return render_template('container_view.html', container=entity)
+@app.route('/container/<uuid:ident>/history', methods=['GET'])
+def container_history(ident):
+ try:
+ entity = api.get_container(str(ident))
+ history = api.get_container_history(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ print(history)
+ return render_template('entity_history.html',
+ page_title=entity.name,
+ entity_type="container",
+ entity=entity,
+ history=history)
+
+@app.route('/container/<uuid:ident>/edit', methods=['GET'])
+def container_edit_view(ident):
+ try:
+ entity = api.get_container(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_edit.html')
+
+#@app.route('/container/<uuid:ident>/edit', methods=['POST'])
+#def container_edit(ident):
+# raise NotImplemented()
+# params = dict()
+# for k in request.form:
+# if k.startswith('container_'):
+# params[k[10:]] = request.form[k]
+# edit = api.update_container(params=params)
+# return redirect("/container/{}".format(edit.ident))
+# # else:
+# #return render_template('container_edit.html')
+
@app.route('/container/create', methods=['GET'])
def container_create_view():
- return render_template('container_add.html')
+ return render_template('container_create.html')
@app.route('/container/create', methods=['POST'])
def container_create():
@@ -51,6 +85,27 @@ def creator_view(ident):
abort(ae.status)
return render_template('creator_view.html', creator=entity, releases=releases)
+@app.route('/creator/<uuid:ident>/history', methods=['GET'])
+def creator_history(ident):
+ try:
+ entity = api.get_creator(str(ident))
+ history = api.get_creator_history(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_history.html',
+ page_title=entity.display_name,
+ entity_type="creator",
+ entity=entity,
+ history=history)
+
+@app.route('/creator/<uuid:ident>/edit', methods=['GET'])
+def creator_edit_view(ident):
+ try:
+ entity = api.get_creator(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_edit.html')
+
@app.route('/creator/lookup', methods=['GET'])
def creator_lookup():
orcid = request.args.get('orcid')
@@ -70,6 +125,27 @@ def file_view(ident):
abort(ae.status)
return render_template('file_view.html', file=entity)
+@app.route('/file/<uuid:ident>/history', methods=['GET'])
+def file_history(ident):
+ try:
+ entity = api.get_file(str(ident))
+ history = api.get_file_history(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_history.html',
+ page_title=None,
+ entity_type="file",
+ entity=entity,
+ history=history)
+
+@app.route('/file/<uuid:ident>/edit', methods=['GET'])
+def file_edit_view(ident):
+ try:
+ entity = api.get_file(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_edit.html')
+
@app.route('/file/lookup', methods=['GET'])
def file_lookup():
sha1 = request.args.get('sha1')
@@ -107,18 +183,39 @@ def release_lookup():
abort(ae.status)
return redirect('/release/{}'.format(resp.ident))
-#@app.route('/release/<uuid:ident>/changelog', methods=['GET'])
-#def release_changelog(ident):
-# try:
-# entity = api.get_release(str(ident))
-# except ApiException as ae:
-# abort(ae.status)
-# try:
-# entries = api.release_changelog(str(ident))
-# except ApiException as ae:
-# abort(ae.status)
-# return render_template('release_changelog.html', release=entity,
-# changelog_entries=entries)
+@app.route('/release/create', methods=['GET'])
+def release_create_view():
+ return render_template('release_create.html')
+
+@app.route('/release/create', methods=['POST'])
+def release_create():
+ params = dict()
+ for k in request.form:
+ if k.startswith('release_'):
+ params[k[10:]] = request.form[k]
+ edit = api.create_release(params=params)
+ return redirect("/release/{}".format(edit.ident))
+
+@app.route('/release/<uuid:ident>/history', methods=['GET'])
+def release_history(ident):
+ try:
+ entity = api.get_release(str(ident))
+ history = api.get_release_history(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_history.html',
+ page_title=entity.title,
+ entity_type="release",
+ entity=entity,
+ history=history)
+
+@app.route('/release/<uuid:ident>/edit', methods=['GET'])
+def release_edit_view(ident):
+ try:
+ entity = api.get_release(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_edit.html')
@app.route('/work/<uuid:ident>', methods=['GET'])
def work_view(ident):
@@ -129,9 +226,26 @@ def work_view(ident):
abort(ae.status)
return render_template('work_view.html', work=entity, releases=releases)
-@app.route('/work/create', methods=['GET'])
-def work_create():
- return render_template('work_add.html')
+@app.route('/work/<uuid:ident>/history', methods=['GET'])
+def work_history(ident):
+ try:
+ entity = api.get_work(str(ident))
+ history = api.get_work_history(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_history.html',
+ page_title=None,
+ entity_type="work",
+ entity=entity,
+ history=history)
+
+@app.route('/work/<uuid:ident>/edit', methods=['GET'])
+def work_edit_view(ident):
+ try:
+ entity = api.get_work(str(ident))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('entity_edit.html')
@app.route('/editgroup/<int:ident>', methods=['GET'])
def editgroup_view(ident):
@@ -160,6 +274,22 @@ def editor_changelog(username):
return render_template('editor_changelog.html', editor=editor,
changelog_entries=changelog_entries)
+@app.route('/changelog', methods=['GET'])
+def changelog_view():
+ try:
+ entries = api.get_changelog(limit=request.args.get('limit'))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('changelog.html', entries=entries)
+
+@app.route('/changelog/<int:index>', methods=['GET'])
+def changelog_entry_view(index):
+ try:
+ entry = api.get_changelog_entry(int(index))
+ except ApiException as ae:
+ abort(ae.status)
+ return render_template('changelog_view.html', entry=entry, editgroup=entry.editgroup)
+
@app.route('/stats', methods=['GET'])
def stats_view():
stats = api.get_stats()
diff --git a/python/fatcat/templates/changelog.html b/python/fatcat/templates/changelog.html
new file mode 100644
index 00000000..ee50a7d2
--- /dev/null
+++ b/python/fatcat/templates/changelog.html
@@ -0,0 +1,23 @@
+{% extends "base.html" %}
+{% block body %}
+
+<h1 class="ui header">Recent Changes
+<div class="sub header"><code>changelog</code></div></h1>
+
+<table class="ui table">
+ <thead><tr><th>Changelog<br>Index
+ <th>Timestamp (UTC)
+ <th>Editgroup
+ <th>Editor
+ <th>Description
+ <tbody>
+ {% for entry in entries %}
+ <tr><td><a href="/changelog/{{ entry.index }}">{{ entry.index }}</a>
+ <td>{{ entry.timestamp }}
+ <td><a href="/editgroup/{{ entry.editgroup_id }}">{{ entry.editgroup_id }}</a>
+ <td><a href="/editor/{{ entry.editgroup.editor_id }}">{{ entry.editgroup.editor_id }}</a>
+ <td>{% if entry.editgroup.description != None %}{{ entry.editgroup.description }}{% endif %}
+ {% endfor %}
+</table>
+
+{% endblock %}
diff --git a/python/fatcat/templates/changelog_view.html b/python/fatcat/templates/changelog_view.html
new file mode 100644
index 00000000..22aff9bc
--- /dev/null
+++ b/python/fatcat/templates/changelog_view.html
@@ -0,0 +1,13 @@
+{% extends "editgroup_view.html" %}
+{% block editgroupheader %}
+
+<h1 class="ui header">Changelog Entry
+<div class="sub header">
+ <code>changelog {{ entry.index }}</code>
+</div>
+</h1>
+
+<br><b>Timestamp:</b> {{ entry.timestamp }}
+<br><b>Editgroup:</b> <a href="/editgroup/{{editgroup.id}}">{{ editgroup.id }}</a>
+
+{% endblock %}
diff --git a/python/fatcat/templates/container_add.html b/python/fatcat/templates/container_create.html
index 15288142..15288142 100644
--- a/python/fatcat/templates/container_add.html
+++ b/python/fatcat/templates/container_create.html
diff --git a/python/fatcat/templates/editgroup_view.html b/python/fatcat/templates/editgroup_view.html
index 06fef424..ac3228b0 100644
--- a/python/fatcat/templates/editgroup_view.html
+++ b/python/fatcat/templates/editgroup_view.html
@@ -1,49 +1,53 @@
{% extends "base.html" %}
{% block body %}
-<h1>Edit Group: #{{ editgroup.id}}</h1>
+{# extended by changelog_entry #}
+{% block editgroupheader %}
+<h1 class="ui header">Edit Group
+<div class="sub header"><code>editgroup {{ editgroup.id }}</code></div></h1>
+{% endblock %}
{# TODO: <p>Editor: <a href="/editor/{{ editgroup.editor.username }}">{{ editgroup.editor.username }}</a> #}
-<p>Editor: {{ editgroup.editor_id }}
-<p>Description: {{ editgroup.description }}
+<br><b>Editor:</b> <a href="/editor/{{editgroup.editor_id}}">{{ editgroup.editor_id }}</a>
+<br><b>Description:</b> {{ editgroup.description }}
-<h3>Work Edits ({{ editgroup.work_edits|count }})</h3>
+<h3>Work Edits ({{ editgroup.edits.works|count }})</h3>
<ul>
-{% for edit in editgroup.work_edits %}
- <li><a href="/work/edit/{{ edit.id }}">Edit #{{ edit.id }}</a>:
- <a href="/work/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.rev }}
+{% for edit in editgroup.edits.works %}
+ <li>Work edit #<a href="/work/edit/{{ edit.edit_id }}">{{ edit.edit_id }}</a>:
+ <a href="/work/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.revision }}
{% endfor %}
</ul>
-<h3>Release Edits ({{ editgroup.release_edits|count }})</h3>
+<h3>Release Edits ({{ editgroup.edits.releases|count }})</h3>
<ul>
-{% for edit in editgroup.release_edits %}
- <li><a href="/release/edit/{{ edit.id }}">Edit #{{ edit.id }}</a>
- <a href="/release/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.rev }}
+{% for edit in editgroup.edits.releases %}
+ <li>Release edit #<a href="/release/edit/{{ edit.edit_id }}">{{ edit.edit_id }}</a>:
+ <a href="/release/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.revision }}
{% endfor %}
</ul>
-<h3>Container Edits ({{ editgroup.container_edits|count }})</h3>
+<h3>Container Edits ({{ editgroup.edits.containers|count }})</h3>
<ul>
-{% for edit in editgroup.container_edits %}
- <li><a href="/container/edit/{{ edit.id }}">Edit #{{ edit.id }}</a>
- <a href="/container/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.rev }}
+{% for edit in editgroup.edits.containers %}
+ <li>Container edit #<a href="/container/edit/{{ edit.edit_id }}">{{ edit.edit_id }}</a>:
+ <a href="/container/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.revision }}
{% endfor %}
</ul>
-<h3>Creator Edits ({{ editgroup.creator_edits|count }})</h3>
+<h3>Creator Edits ({{ editgroup.edits.creators|count }})</h3>
<ul>
-{% for edit in editgroup.creator_edits %}
- <li><a href="/creator/edit/{{ edit.id }}">Edit #{{ edit.id }}</a>
- <a href="/creator/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.rev }}
+{% for edit in editgroup.edits.creators %}
+ <li>Creator edit #<a href="/creator/edit/{{ edit.edit_id }}">{{ edit.edit_id }}</a>:
+ <a href="/creator/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.revision }}
{% endfor %}
</ul>
-<h3>File Edits ({{ editgroup.file_edits|count }})</h3>
+<h3>File Edits ({{ editgroup.edits.files|count }})</h3>
<ul>
-{% for edit in editgroup.file_edits %}
- <li><a href="/file/edit/{{ edit.id }}">Edit #{{ edit.id }}</a>
- <a href="/file/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.rev }}
+{% for edit in editgroup.edits.files %}
+ <li>File edit #<a href="/file/edit/{{ edit.edit_id }}">{{ edit.edit_id }}</a>:
+ <a href="/file/{{ edit.ident }}">{{ edit.ident }}</a> to rev {{ edit.revision }}
{% endfor %}
</ul>
diff --git a/python/fatcat/templates/editor_changelog.html b/python/fatcat/templates/editor_changelog.html
index e1410874..543d6bac 100644
--- a/python/fatcat/templates/editor_changelog.html
+++ b/python/fatcat/templates/editor_changelog.html
@@ -1,9 +1,13 @@
{% extends "base.html" %}
{% block body %}
-<h1>Editor Changelog: {{ editor.username }}</h1>
-
-<p>Editor: <a href="/editor/{{ editor.username }}">{{ editor.username }}</a>
+<h1 class="ui header">Editor Changelog: {{ editor.username }}
+<div class="sub header">
+ <a href="/editor/{{editor.id}}">
+ <code>editor {{ editor.id }}</code>
+ </a>
+</div>
+</h1>
<p>Changes accepted (aka, merged editgroups):
<ul>
diff --git a/python/fatcat/templates/editor_view.html b/python/fatcat/templates/editor_view.html
index e0625c42..f58b85b5 100644
--- a/python/fatcat/templates/editor_view.html
+++ b/python/fatcat/templates/editor_view.html
@@ -1,7 +1,11 @@
{% extends "base.html" %}
{% block body %}
-<h1>Editor: {{ editor.username }}</h1>
+<h1 class="ui header">{{ editor.username }}
+<div class="sub header">
+ <code>editor {{ editor.id }}</code>
+</div>
+</h1>
<p>Is Admin? {{ editor.is_admin }}
<p><a href="/editor/{{ editor.username }}/changelog">Changelog</a>
diff --git a/python/fatcat/templates/entity_edit.html b/python/fatcat/templates/entity_edit.html
new file mode 100644
index 00000000..5da98d89
--- /dev/null
+++ b/python/fatcat/templates/entity_edit.html
@@ -0,0 +1,8 @@
+{% extends "base.html" %}
+{% block body %}
+
+<h1>Not Implemented</h1>
+
+Entity editing isn't implemented yet, only creation. Sorry!
+
+{% endblock %}
diff --git a/python/fatcat/templates/entity_history.html b/python/fatcat/templates/entity_history.html
new file mode 100644
index 00000000..54577b2f
--- /dev/null
+++ b/python/fatcat/templates/entity_history.html
@@ -0,0 +1,30 @@
+{% extends "base.html" %}
+{% block body %}
+
+<h1 class="ui header">{% if page_title != None %}{{ page_title }}{% endif %}
+<div class="sub header">
+ <a href="/{{entity_type}}/{{entity.ident}}">
+ <code>{{ entity_type }} {{ entity.ident }}</code>
+ </a>
+</div>
+</h1>
+
+<h3 class="ui header">Fatcat Metadata Edit History</h3>
+
+<table class="ui table">
+ <thead><tr><th>Changelog<br>Index
+ <th>Timestamp (UTC)
+ <th>Editgroup
+ <th>Editor
+ <th>Description
+ <tbody>
+ {% for entry in history %}
+ <tr><td><a href="/changelog/{{ entry.changelog_entry.index }}">{{ entry.changelog_entry.index }}</a>
+ <td>{{ entry.changelog_entry.timestamp }}
+ <td><a href="/editgroup/{{ entry.editgroup.id }}">{{ entry.editgroup.id }}</a>
+ <td><a href="/editor/{{ entry.editgroup.editor_id }}">{{ entry.editgroup.editor_id }}</a>
+ <td>{% if entry.editgroup.description != None %}{{ entry.editgroup.description }}{% endif %}
+ {% endfor %}
+</table>
+
+{% endblock %}
diff --git a/python/fatcat/templates/home.html b/python/fatcat/templates/home.html
index 0ec0bd18..9a8a55c8 100644
--- a/python/fatcat/templates/home.html
+++ b/python/fatcat/templates/home.html
@@ -27,11 +27,11 @@ indexing (aka, linking together of pre-prints and final copies).
<td><a href="/container/00000000-0000-0000-1111-000000000002">Fake</a>
<br><a href="/container/00000000-0000-0000-1111-000000000003">Real</a>
<tr><td><b>Creator</b>
- <td><a href="/creator/create">Create</a>
+ <td><!-- <a href="/creator/create">Create</a> -->
<td><a href="/creator/00000000-0000-0000-2222-000000000002">Fake</a>
<br><a href="/creator/00000000-0000-0000-2222-000000000003">Real</a>
<tr><td><b>File</b>
- <td><a href="/file/create">Create</a>
+ <td>
<td><a href="/file/00000000-0000-0000-3333-000000000002">Fake</a>
<br><a href="/file/00000000-0000-0000-3333-000000000003">Real</a>
<tr><td><b>Release</b>
@@ -39,7 +39,7 @@ indexing (aka, linking together of pre-prints and final copies).
<td><a href="/release/00000000-0000-0000-4444-000000000002">Fake</a>
<br><a href="/release/00000000-0000-0000-4444-000000000003">Real</a>
<tr><td><b>Work</b>
- <td><a href="/work/create">Create</a>
+ <td>
<td><a href="/work/00000000-0000-0000-5555-000000000002">Fake</a>
<br><a href="/work/00000000-0000-0000-5555-000000000003">Real</a>
</table>
diff --git a/python/fatcat/templates/work_add.html b/python/fatcat/templates/release_create.html
index ac8a8169..ac8a8169 100644
--- a/python/fatcat/templates/work_add.html
+++ b/python/fatcat/templates/release_create.html