summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-07-30 17:31:17 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-07-30 23:45:30 -0700
commitb14040ecb359d1575280b24eaab9bd0e4964e3f7 (patch)
treeea14210d32a0668fa4792ac807e05176c43bcde3
parent90b06f6f6db1a40946ba280f7324b15fec2f667e (diff)
downloadfatcat-b14040ecb359d1575280b24eaab9bd0e4964e3f7.tar.gz
fatcat-b14040ecb359d1575280b24eaab9bd0e4964e3f7.zip
wire up new TOML views
-rw-r--r--python/fatcat_web/editing_routes.py193
-rw-r--r--python/fatcat_web/templates/container_create.html4
-rw-r--r--python/fatcat_web/templates/container_edit.html5
-rw-r--r--python/fatcat_web/templates/edit_macros.html2
-rw-r--r--python/fatcat_web/templates/editgroup_view.html2
-rw-r--r--python/fatcat_web/templates/entity_edit.html8
-rw-r--r--python/fatcat_web/templates/entity_edit_toml.html12
-rw-r--r--python/fatcat_web/templates/file_create.html4
-rw-r--r--python/fatcat_web/templates/file_edit.html5
-rw-r--r--python/fatcat_web/templates/home.html12
-rw-r--r--python/fatcat_web/templates/release_create.html4
-rw-r--r--python/fatcat_web/templates/release_edit.html6
-rw-r--r--python/tests/web_editing.py66
-rw-r--r--python/tests/web_entity_views.py16
14 files changed, 256 insertions, 83 deletions
diff --git a/python/fatcat_web/editing_routes.py b/python/fatcat_web/editing_routes.py
index f3c6fdd0..e84b14f7 100644
--- a/python/fatcat_web/editing_routes.py
+++ b/python/fatcat_web/editing_routes.py
@@ -366,27 +366,18 @@ def generic_edit_delete(editgroup_id, entity_type, edit_id):
try:
editgroup = api.get_editgroup(editgroup_id)
except ApiException as ae:
- raise ae
+ abort(ae.status)
# check that editgroup is edit-able
if editgroup.changelog_index != None:
- abort(400, "Editgroup already merged")
+ flash("Editgroup already merged")
+ abort(400)
# API on behalf of user
user_api = auth_api(session['api_token'])
# do the deletion
- try:
- if entity_type == 'container':
- user_api.delete_container_edit(editgroup.editgroup_id, edit_id)
- elif entity_type == 'file':
- user_api.delete_file_edit(editgroup.editgroup_id, edit_id)
- elif entity_type == 'release':
- user_api.delete_release_edit(editgroup.editgroup_id, edit_id)
- else:
- raise NotImplementedError
- except ApiException as ae:
- raise ae
+ generic_entity_delete_edit(user_api, entity_type, editgroup.editgroup_id, edit_id)
return redirect("/editgroup/{}".format(editgroup_id))
@@ -452,69 +443,187 @@ def release_editgroup_edit(editgroup_id, ident):
def release_edit_delete(editgroup_id, edit_id):
return generic_edit_delete(editgroup_id, 'release', edit_id)
+@app.route('/editgroup/<editgroup_id>/creator/edit/<edit_id>/delete', methods=['POST'])
+def creator_edit_delete(editgroup_id, edit_id):
+ return generic_edit_delete(editgroup_id, 'creator', edit_id)
+
+@app.route('/editgroup/<editgroup_id>/fileset/edit/<edit_id>/delete', methods=['POST'])
+def fileset_edit_delete(editgroup_id, edit_id):
+ return generic_edit_delete(editgroup_id, 'fileset', edit_id)
-### Not-Implemented Views ###################################################
+@app.route('/editgroup/<editgroup_id>/webcapture/edit/<edit_id>/delete', methods=['POST'])
+def webcapture_edit_delete(editgroup_id, edit_id):
+ return generic_edit_delete(editgroup_id, 'webcapture', edit_id)
+
+@app.route('/editgroup/<editgroup_id>/work/edit/<edit_id>/delete', methods=['POST'])
+def work_edit_delete(editgroup_id, edit_id):
+ return generic_edit_delete(editgroup_id, 'work', edit_id)
+
+### TOML Views ##############################################################
+
+@app.route('/container/create/toml', methods=['GET', 'POST'])
+@login_required
+def container_create_toml_view():
+ return generic_entity_toml_edit(None, 'container', None, 'entity_create_toml.html')
+
+@app.route('/container/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def container_edit_toml(ident):
+ return generic_entity_toml_edit(None, 'container', ident, 'entity_edit_toml.html')
+
+@app.route('/editgroup/<editgroup_id>/container/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def container_editgroup_edit_toml(editgroup_id, ident):
+ return generic_entity_toml_edit(editgroup_id, 'container', ident, 'entity_edit_toml.html')
+
+@app.route('/creator/create/toml', methods=['GET', 'POST'])
+@login_required
+def creator_create_toml_view():
+ return generic_entity_toml_edit(None, 'creator', None, 'entity_create_toml.html')
+
+@app.route('/creator/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def creator_edit_toml(ident):
+ return generic_entity_toml_edit(None, 'creator', ident, 'entity_edit_toml.html')
+
+@app.route('/editgroup/<editgroup_id>/creator/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def creator_editgroup_edit_toml(editgroup_id, ident):
+ return generic_entity_toml_edit(editgroup_id, 'creator', ident, 'entity_edit_toml.html')
+
+@app.route('/file/create/toml', methods=['GET', 'POST'])
+@login_required
+def file_create_toml_view():
+ return generic_entity_toml_edit(None, 'file', None, 'entity_create_toml.html')
+
+@app.route('/file/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def file_edit_toml(ident):
+ return generic_entity_toml_edit(None, 'file', ident, 'entity_edit_toml.html')
+
+@app.route('/editgroup/<editgroup_id>/file/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def file_editgroup_edit_toml(editgroup_id, ident):
+ return generic_entity_toml_edit(editgroup_id, 'file', ident, 'entity_edit_toml.html')
+
+@app.route('/fileset/create/toml', methods=['GET', 'POST'])
+@login_required
+def fileset_create_toml_view():
+ return generic_entity_toml_edit(None, 'fileset', None, 'entity_create_toml.html')
+
+@app.route('/fileset/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def fileset_edit_toml(ident):
+ return generic_entity_toml_edit(None, 'fileset', ident, 'entity_edit_toml.html')
+
+@app.route('/editgroup/<editgroup_id>/fileset/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def fileset_editgroup_edit_toml(editgroup_id, ident):
+ return generic_entity_toml_edit(editgroup_id, 'fileset', ident, 'entity_edit_toml.html')
+
+@app.route('/webcapture/create/toml', methods=['GET', 'POST'])
+@login_required
+def webcapture_create_toml_view():
+ return generic_entity_toml_edit(None, 'webcapture', None, 'entity_create_toml.html')
+
+@app.route('/webcapture/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def webcapture_edit_toml(ident):
+ return generic_entity_toml_edit(None, 'webcapture', ident, 'entity_edit_toml.html')
+
+@app.route('/editgroup/<editgroup_id>/webcapture/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def webcapture_editgroup_edit_toml(editgroup_id, ident):
+ return generic_entity_toml_edit(editgroup_id, 'webcapture', ident, 'entity_edit_toml.html')
+
+@app.route('/release/create/toml', methods=['GET', 'POST'])
+@login_required
+def release_create_toml_view():
+ return generic_entity_toml_edit(None, 'release', None, 'entity_create_toml.html')
+
+@app.route('/release/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def release_edit_toml(ident):
+ return generic_entity_toml_edit(None, 'release', ident, 'entity_edit_toml.html')
+
+@app.route('/editgroup/<editgroup_id>/release/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def release_editgroup_edit_toml(editgroup_id, ident):
+ return generic_entity_toml_edit(editgroup_id, 'release', ident, 'entity_edit_toml.html')
+
+@app.route('/work/create/toml', methods=['GET', 'POST'])
+@login_required
+def work_create_toml_view():
+ return generic_entity_toml_edit(None, 'work', None, 'entity_create_toml.html')
+
+@app.route('/work/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def work_edit_toml(ident):
+ return generic_entity_toml_edit(None, 'work', ident, 'entity_edit_toml.html')
+
+@app.route('/editgroup/<editgroup_id>/work/<ident>/edit/toml', methods=['GET', 'POST'])
+@login_required
+def work_editgroup_edit_toml(editgroup_id, ident):
+ return generic_entity_toml_edit(editgroup_id, 'work', ident, 'entity_edit_toml.html')
+
+### TOML-Only Editing Redirects ################################################
@app.route('/creator/create', methods=['GET'])
+@login_required
def creator_create_view():
- return abort(404)
+ return redirect('/creator/create/toml')
@app.route('/creator/<ident>/edit', methods=['GET'])
+@login_required
def creator_edit(ident):
- return render_template('entity_edit.html'), 404
+ return redirect(f'/creator/{ident}/edit/toml')
@app.route('/editgroup/<editgroup_id>/creator/<ident>/edit', methods=['GET', 'POST'])
+@login_required
def creator_editgroup_edit(editgroup_id, ident):
- return abort(404)
-
-@app.route('/editgroup/<editgroup_id>/creator/edit/<edit_id>/delete', methods=['POST'])
-def creator_edit_delete(editgroup_id, edit_id):
- return abort(404)
+ return redirect(f'/editgroup/{editgroup_id}/creator/{ident}/edit/toml')
@app.route('/fileset/create', methods=['GET'])
+@login_required
def fileset_create_view():
- return abort(404)
+ return redirect('/fileset/create/toml')
@app.route('/fileset/<ident>/edit', methods=['GET'])
+@login_required
def fileset_edit(ident):
- return render_template('entity_edit.html'), 404
+ return redirect(f'/fileset/{ident}/edit/toml')
@app.route('/editgroup/<editgroup_id>/fileset/<ident>/edit', methods=['GET', 'POST'])
+@login_required
def fileset_editgroup_edit(editgroup_id, ident):
- return abort(404)
-
-@app.route('/editgroup/<editgroup_id>/fileset/edit/<edit_id>/delete', methods=['POST'])
-def fileset_edit_delete(editgroup_id, edit_id):
- return abort(404)
+ return redirect(f'/editgroup/{editgroup_id}/fileset/{ident}/edit/toml')
@app.route('/webcapture/create', methods=['GET'])
+@login_required
def webcapture_create_view():
- return abort(404)
+ return redirect('/webcapture/create/toml')
@app.route('/webcapture/<ident>/edit', methods=['GET'])
+@login_required
def webcapture_edit(ident):
- return render_template('entity_edit.html'), 404
+ return redirect(f'/webcapture/{ident}/edit/toml')
@app.route('/editgroup/<editgroup_id>/webcapture/<ident>/edit', methods=['GET', 'POST'])
+@login_required
def webcapture_editgroup_edit(editgroup_id, ident):
- return abort(404)
-
-@app.route('/editgroup/<editgroup_id>/webcapture/edit/<edit_id>/delete', methods=['POST'])
-def webcapture_edit_delete(editgroup_id, edit_id):
- return abort(404)
+ return redirect(f'/editgroup/{editgroup_id}/webcapture/{ident}/edit/toml')
@app.route('/work/create', methods=['GET'])
+@login_required
def work_create_view():
- return abort(404)
+ return redirect('/work/create/toml')
@app.route('/work/<ident>/edit', methods=['GET'])
+@login_required
def work_edit(ident):
- return render_template('entity_edit.html'), 404
+ return redirect(f'/work/{ident}/edit/toml')
@app.route('/editgroup/<editgroup_id>/work/<ident>/edit', methods=['GET', 'POST'])
+@login_required
def work_editgroup_edit(editgroup_id, ident):
- return abort(404)
-
-@app.route('/editgroup/<editgroup_id>/work/edit/<edit_id>/delete', methods=['POST'])
-def work_edit_delete(editgroup_id, edit_id):
- return abort(404)
+ return redirect(f'/editgroup/{editgroup_id}/work/{ident}/edit/toml')
diff --git a/python/fatcat_web/templates/container_create.html b/python/fatcat_web/templates/container_create.html
index 5786d05d..be8c5671 100644
--- a/python/fatcat_web/templates/container_create.html
+++ b/python/fatcat_web/templates/container_create.html
@@ -9,13 +9,15 @@ a journal (eg, "New England Journal of Medicine"), conference proceedings, a
book series, or a blog. Not all publications are in a container.
<form class="ui form" id="create_container_form" method="POST" action="/container/create">
+ <p>Experienced users can also use the <a href="/container/create/toml">TOML
+ creation form</a> to access all metadata fields in a raw format.
{% endblock %}
{% block edit_form_suffix %}
<br><br>
<input class="ui primary submit button" type="submit" value="Create Container!">
<p>
- <i>New entity will be part of the current editgroup, which needs to be
+ <i>New container entity will be part of the current editgroup, which needs to be
submited and approved before the entity will formally be included in the
catalog.</i>
</form>
diff --git a/python/fatcat_web/templates/container_edit.html b/python/fatcat_web/templates/container_edit.html
index 5188ce0d..fd07b3da 100644
--- a/python/fatcat_web/templates/container_edit.html
+++ b/python/fatcat_web/templates/container_edit.html
@@ -7,6 +7,11 @@
<h1 class="ui header">Edit Container Entity</h1>
<form class="ui form" id="edit_container_form" method="POST" action="{% if editgroup %}/editgroup/{{ editgroup.editgroup_id }}{% endif %}/container/{{ existing_ident }}/edit">
+
+ <p>Experienced users can also use the <a href="{% if editgroup
+ %}/editgroup/{{ editgroup.editgroup_id }}{% endif %}/container/{{
+ existing_ident }}/edit/toml">TOML editing form</a> to access all metadata
+ fields in a raw format.
{% endblock %}
<p>See <a href="https://guide.fatcat.wiki/entity_container.html">the catalog
diff --git a/python/fatcat_web/templates/edit_macros.html b/python/fatcat_web/templates/edit_macros.html
index 60c17aa9..d4839373 100644
--- a/python/fatcat_web/templates/edit_macros.html
+++ b/python/fatcat_web/templates/edit_macros.html
@@ -55,7 +55,7 @@
{% macro editgroup_dropdown(form, editgroup=None, potential_editgroups=None) -%}
{% if editgroup %}
<p>You are updating an existing un-merged editgroup: <a href="/editgroup/{{ editgroup.editgroup_id}}">{{ editgroup.editgroup_id }}</a>.
- <p><b>Description:</b> {{ editgroup.description }}
+ <p><b>Description:</b> {{ editgroup.description or "" }}
{% else %}
{% if not potential_editgroups %}
<p>You have no un-submitted editgroups in progress; a new one will be
diff --git a/python/fatcat_web/templates/editgroup_view.html b/python/fatcat_web/templates/editgroup_view.html
index e8146d19..a36dc3e5 100644
--- a/python/fatcat_web/templates/editgroup_view.html
+++ b/python/fatcat_web/templates/editgroup_view.html
@@ -25,7 +25,7 @@
updated
{% endif %}
<a href="/editgroup/{{ editgroup.editgroup_id }}/{{ entity_type }}/{{ edit.ident }}">[view edit]</a>
- {% if auth_to.edit and not editgroup.changelog_index and not editgroup.submitted and entity_type in ('release', 'file', 'container') %}
+ {% if auth_to.edit and not editgroup.changelog_index and not editgroup.submitted %}
<a href="/editgroup/{{ editgroup.editgroup_id }}/{{ entity_type }}/{{ edit.ident }}/edit" style="color: green;">[re-edit]</a>
<form id="submit_edit_delete" method="POST" action="/editgroup/{{ editgroup.editgroup_id }}/{{ entity_type }}/edit/{{ edit.edit_id }}/delete" style="display:inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
diff --git a/python/fatcat_web/templates/entity_edit.html b/python/fatcat_web/templates/entity_edit.html
deleted file mode 100644
index 97f7bf46..00000000
--- a/python/fatcat_web/templates/entity_edit.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{% extends "base.html" %}
-{% block body %}
-
-<h1>Not Implemented</h1>
-
-<p>Entity editing via the web interface isn't implemented yet. Sorry!
-
-{% endblock %}
diff --git a/python/fatcat_web/templates/entity_edit_toml.html b/python/fatcat_web/templates/entity_edit_toml.html
index 4b6e7b6d..807e4d2b 100644
--- a/python/fatcat_web/templates/entity_edit_toml.html
+++ b/python/fatcat_web/templates/entity_edit_toml.html
@@ -37,3 +37,15 @@
{% endblock %}
{% endblock %}
+{% block postscript %}
+<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
+<script>
+<!-- Form code -->
+$(document).ready(function() {
+
+ // these javascript dropdowns hide the original <input>, which breaks browser
+ // form focusing (eg, for required fields) :(
+ $('.ui.dropdown') .dropdown();
+});
+</script>
+{% endblock %}
diff --git a/python/fatcat_web/templates/file_create.html b/python/fatcat_web/templates/file_create.html
index a7c99b96..affcfb6e 100644
--- a/python/fatcat_web/templates/file_create.html
+++ b/python/fatcat_web/templates/file_create.html
@@ -5,13 +5,15 @@
<h1 class="ui header">Create New File Entity</h1>
<form class="ui form" id="create_file_form" method="POST" action="/file/create">
+ <p>Experienced users can also use the <a href="/file/create/toml">TOML
+ creation form</a> to access all metadata fields in a raw format.
{% endblock %}
{% block edit_form_suffix %}
<br><br>
<input class="ui primary submit button" type="submit" value="Create File!">
<p>
- <i>New entity will be part of the current editgroup, which needs to be
+ <i>New file entity will be part of the current editgroup, which needs to be
submited and approved before the entity will formally be included in the
catalog.</i>
</form>
diff --git a/python/fatcat_web/templates/file_edit.html b/python/fatcat_web/templates/file_edit.html
index e8a421b3..b7876fc5 100644
--- a/python/fatcat_web/templates/file_edit.html
+++ b/python/fatcat_web/templates/file_edit.html
@@ -7,6 +7,11 @@
<h1 class="ui header">Edit File Entity</h1>
<form class="ui form" id="edit_file_form" method="POST" action="{% if editgroup %}/editgroup/{{ editgroup.editgroup_id }}{% endif %}/file/{{ existing_ident }}/edit">
+
+ <p>Experienced users can also use the <a href="{% if editgroup
+ %}/editgroup/{{ editgroup.editgroup_id }}{% endif %}/file/{{
+ existing_ident }}/edit/toml">TOML editing form</a> to access all metadata
+ fields in a raw format.
{% endblock %}
<p>See <a href="https://guide.fatcat.wiki/entity_file.html">the catalog
diff --git a/python/fatcat_web/templates/home.html b/python/fatcat_web/templates/home.html
index 4557e212..de32d6a4 100644
--- a/python/fatcat_web/templates/home.html
+++ b/python/fatcat_web/templates/home.html
@@ -171,11 +171,10 @@
<tr><td><b>Creator</b>
<br>authors, editors, translators
+ <td><a href="/creator/create">Create</a>
{% if config.FATCAT_DOMAIN == 'fatcat.wiki' %}
- <td>
<td><a href="/creator/iimvc523xbhqlav6j3sbthuehu">Author</a>
{% else %}
- <td><!-- <a href="/creator/create">Create</a> -->
<td><a href="/creator/iimvc523xbhqlav6j3sbthuehu">Author</a> (prod)
<br><a href="/creator/aaaaaaaaaaaaaircaaaaaaaaai">Dummy</a>
<br><a href="/creator/aaaaaaaaaaaaaircaaaaaaaaam">Realistic</a>
@@ -206,11 +205,10 @@
</form>
<tr><td><b>File Set</b>
<br>datasets, suplementary materials
+ <td><a href="/fileset/create">Create</a>
{% if config.FATCAT_DOMAIN == 'fatcat.wiki' %}
- <td>
<td><a href="/fileset/ho376wmdanckpp66iwfs7g22ne">Dataset</a>
{% else %}
- <td>
<td><a href="/fileset/ho376wmdanckpp66iwfs7g22ne">Dataset</a> (prod)
<br><a href="/fileset/aaaaaaaaaaaaaztgaaaaaaaaai">Dummy</a>
<br><a href="/fileset/aaaaaaaaaaaaaztgaaaaaaaaam">Realistic</a>
@@ -218,12 +216,11 @@
<td>
<tr><td><b>Web Capture</b>
<br>HTML and interactive articles, blog posts
+ <td><a href="/webcapture/create">Create</a>
{% if config.FATCAT_DOMAIN == 'fatcat.wiki' %}
- <td>
<td><a href="/webcapture/z7uaeatyvfgwdpuxtrdu4okqii">D-Lib</a>
<br><a href="/webcapture/5l2pubtfefbmdnqws2izccqlpm">Blog Post</a>
{% else %}
- <td>
<td><a href="/webcapture/z7uaeatyvfgwdpuxtrdu4okqii">D-Lib</a> (prod)
<br><a href="/webcapture/aaaaaaaaaaaaa53xaaaaaaaaai">Dummy</a>
<br><a href="/webcapture/aaaaaaaaaaaaa53xaaaaaaaaam">Realistic</a>
@@ -231,11 +228,10 @@
<td>
<tr><td><b>Work</b>
<br>for grouping Releases
+ <td><a href="/work/create">Create</a>
{% if config.FATCAT_DOMAIN == 'fatcat.wiki' %}
- <td>
<td><a href="/work/ftl6xv267vb6xfech3khri3nwa">Paper</a>
{% else %}
- <td>
<td><a href="/work/ftl6xv267vb6xfech3khri3nwa">Paper</a> (prod)
<br><a href="/work/aaaaaaaaaaaaavkvaaaaaaaaai">Dummy</a>
<br><a href="/work/aaaaaaaaaaaaavkvaaaaaaaaam">Realistic</a>
diff --git a/python/fatcat_web/templates/release_create.html b/python/fatcat_web/templates/release_create.html
index 5ec2efe5..4f5dabd7 100644
--- a/python/fatcat_web/templates/release_create.html
+++ b/python/fatcat_web/templates/release_create.html
@@ -5,13 +5,15 @@
<h1 class="ui header">Create New Release Entity</h1>
<form class="ui form" id="create_release_form" method="POST" action="/release/create">
+ <p>Experienced users can also use the <a href="/release/create/toml">TOML
+ creation form</a> to access all metadata fields in a raw format.
{% endblock %}
{% block edit_form_suffix %}
<br><br>
<input class="ui primary submit button" type="submit" value="Create Release!">
<p>
- <i>New entity will be part of the current editgroup, which needs to be
+ <i>New release entity will be part of the current editgroup, which needs to be
submited and approved before the entity will formally be included in the
catalog.</i>
</form>
diff --git a/python/fatcat_web/templates/release_edit.html b/python/fatcat_web/templates/release_edit.html
index a4a7e56f..21c8cf68 100644
--- a/python/fatcat_web/templates/release_edit.html
+++ b/python/fatcat_web/templates/release_edit.html
@@ -7,6 +7,11 @@
<h1 class="ui header">Edit Release Entity</h1>
<form class="ui form" id="edit_release_form" method="POST" action="{% if editgroup %}/editgroup/{{ editgroup.editgroup_id }}{% endif %}/release/{{ existing_ident }}/edit">
+
+ <p>Experienced users can also use the <a href="{% if editgroup
+ %}/editgroup/{{ editgroup.editgroup_id }}{% endif %}/release/{{
+ existing_ident }}/edit/toml">TOML editing form</a> to access all metadata
+ fields in a raw format.
{% endblock %}
<p>See <a href="https://guide.fatcat.wiki/entity_release.html">the catalog
@@ -14,6 +19,7 @@
href="https://guide.fatcat.wiki/editing_quickstart.html">the editing
tutorial</a> if this is your first time making an edit.
+
{{ form.hidden_tag() }}
<h3 class="ui dividing header">Editgroup Metadata</h3>
diff --git a/python/tests/web_editing.py b/python/tests/web_editing.py
index 17f4f5ae..ea244388 100644
--- a/python/tests/web_editing.py
+++ b/python/tests/web_editing.py
@@ -2,7 +2,7 @@
from fixtures import *
-def test_web_release_create_merge(app_admin, api):
+def test_web_release_create_accept(app_admin, api):
eg = quick_eg(api)
@@ -129,18 +129,60 @@ def test_web_file_create(app_admin, api):
follow_redirects=True)
assert rv.status_code == 200
+DUMMY_DEMO_ENTITIES = {
+ 'container': 'aaaaaaaaaaaaaeiraaaaaaaaam',
+ 'creator': 'aaaaaaaaaaaaaircaaaaaaaaaq',
+ 'file': 'aaaaaaaaaaaaamztaaaaaaaaam',
+ 'fileset': 'aaaaaaaaaaaaaztgaaaaaaaaai',
+ 'webcapture': 'aaaaaaaaaaaaa53xaaaaaaaaai',
+ 'release': 'aaaaaaaaaaaaarceaaaaaaaaai',
+ 'work': 'aaaaaaaaaaaaavkvaaaaaaaaai',
+}
def test_web_edit_get(app_admin):
# these are all existing entities
- rv = app_admin.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/edit')
- assert rv.status_code == 200
- assert b'A bigger example' in rv.data
-
- rv = app_admin.get('/file/aaaaaaaaaaaaamztaaaaaaaaam/edit')
- assert rv.status_code == 200
- assert b'ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362' in rv.data
-
- rv = app_admin.get('/container/aaaaaaaaaaaaaeiraaaaaaaaam/edit')
- assert rv.status_code == 200
- assert b'1549-1277' in rv.data
+ for entity_type in ['release', 'file', 'container']:
+ rv = app_admin.get(f'/{entity_type}/{DUMMY_DEMO_ENTITIES[entity_type]}/edit')
+ assert rv.status_code == 200
+ if entity_type == 'release':
+ assert b'A bigger example' in rv.data
+ elif entity_type == 'file':
+ assert b'ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362' in rv.data
+ elif entity_type == 'container':
+ assert b'1549-1277' in rv.data
+
+ rv = app_admin.get(f'/{entity_type}/{DUMMY_DEMO_ENTITIES[entity_type]}/edit/toml')
+ assert rv.status_code == 200
+ if entity_type == 'release':
+ assert b'A bigger example' in rv.data
+ elif entity_type == 'file':
+ assert b'ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362' in rv.data
+ elif entity_type == 'container':
+ assert b'1549-1277' in rv.data
+
+ # TOML-only endpoints
+ for entity_type in ['creator', 'fileset', 'webcapture', 'work']:
+ rv = app_admin.get(f'/{entity_type}/{DUMMY_DEMO_ENTITIES[entity_type]}/edit')
+ assert rv.status_code == 302
+
+ rv = app_admin.get(f'/{entity_type}/{DUMMY_DEMO_ENTITIES[entity_type]}/edit/toml')
+ assert rv.status_code == 200
+
+
+def test_web_create_get(app_admin):
+
+ for entity_type in ['release', 'file', 'container']:
+ rv = app_admin.get(f'/{entity_type}/create')
+ assert rv.status_code == 200
+
+ rv = app_admin.get(f'/{entity_type}/create/toml')
+ assert rv.status_code == 200
+
+ # these are TOML only
+ for entity_type in ['creator', 'fileset', 'webcapture', 'work']:
+ rv = app_admin.get(f'/{entity_type}/create')
+ assert rv.status_code == 302
+
+ rv = app_admin.get(f'/{entity_type}/create/toml')
+ assert rv.status_code == 200
diff --git a/python/tests/web_entity_views.py b/python/tests/web_entity_views.py
index b01bd815..7b973ef2 100644
--- a/python/tests/web_entity_views.py
+++ b/python/tests/web_entity_views.py
@@ -210,9 +210,9 @@ def test_web_creator(app):
rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai')
assert rv.status_code == 200
rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/edit')
- assert rv.status_code == 404
+ assert rv.status_code == 302
rv = app.get('/creator/create')
- assert rv.status_code == 404
+ assert rv.status_code == 302
def test_web_file(app):
@@ -266,9 +266,9 @@ def test_web_fileset(app):
rv = app.get('/fileset/aaaaaaaaaaaaaztgaaaaaaaaai')
assert rv.status_code == 200
rv = app.get('/fileset/aaaaaaaaaaaaaztgaaaaaaaaai/edit')
- assert rv.status_code == 404
+ assert rv.status_code == 302
rv = app.get('/fileset/create')
- assert rv.status_code == 404
+ assert rv.status_code == 302
def test_web_webcatpure(app):
@@ -277,9 +277,9 @@ def test_web_webcatpure(app):
rv = app.get('/webcapture/aaaaaaaaaaaaa53xaaaaaaaaai')
assert rv.status_code == 200
rv = app.get('/webcapture/aaaaaaaaaaaaa53xaaaaaaaaai/edit')
- assert rv.status_code == 404
+ assert rv.status_code == 302
rv = app.get('/webcapture/create')
- assert rv.status_code == 404
+ assert rv.status_code == 302
def test_web_release(app):
@@ -376,6 +376,6 @@ def test_web_work(app):
rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai')
assert rv.status_code == 200
rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai/edit')
- assert rv.status_code == 404
+ assert rv.status_code == 302
rv = app.get('/work/create')
- assert rv.status_code == 404
+ assert rv.status_code == 302