summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fatcat/api.py2
-rw-r--r--fatcat/models.py1
-rw-r--r--fatcat/routes.py14
-rw-r--r--fatcat/templates/editgroup_view.html15
-rw-r--r--tests/routes.py3
5 files changed, 34 insertions, 1 deletions
diff --git a/fatcat/api.py b/fatcat/api.py
index 6037b250..905a4317 100644
--- a/fatcat/api.py
+++ b/fatcat/api.py
@@ -220,6 +220,7 @@ def api_file_create():
@app.route('/v0/editgroup/<int:ident>', methods=['GET'])
def api_edit_group_get(ident):
entity = EditGroup.query.filter(EditGroup.id==ident).first_or_404()
+ # TODO: fill in all the related edit types...
return edit_group_schema.jsonify(entity)
@app.route('/v0/editgroup', methods=['POST'])
@@ -241,4 +242,3 @@ def api_edit_group_accept(ident):
entity = EditGroup.query.filter(EditGroup.id==ident).first_or_404()
accept_editgroup(entity)
return jsonify({'success': True})
-
diff --git a/fatcat/models.py b/fatcat/models.py
index ad00b62d..957c929f 100644
--- a/fatcat/models.py
+++ b/fatcat/models.py
@@ -249,6 +249,7 @@ class EditGroup(db.Model):
editor = db.relationship('Editor', foreign_keys='EditGroup.editor_id')
extra_json_id = db.Column(db.ForeignKey('extra_json.sha1'), nullable=True)
extra_json = db.relationship("ExtraJson")
+ # TODO: changelog entry relationship
class Editor(db.Model):
__tablename__ = 'editor'
diff --git a/fatcat/routes.py b/fatcat/routes.py
index 2e77e7ac..3bfcf58a 100644
--- a/fatcat/routes.py
+++ b/fatcat/routes.py
@@ -69,6 +69,20 @@ def file_view(ident):
entity = json.loads(rv.data.decode('utf-8'))
return render_template('file_view.html', file=entity)
+@app.route('/editgroup/<int:ident>', methods=['GET'])
+def editgroup_view(ident):
+ rv = api.api_edit_group_get(ident)
+ if rv.status_code != 200:
+ # TODO: better wrapping for all entities
+ return abort(rv.status_code)
+ entity = json.loads(rv.data.decode('utf-8'))
+ return render_template('editgroup_view.html', editgroup=entity)
+
+@app.route('/editgroup/current', methods=['GET'])
+def editgroup_current(ident):
+ eg = api.get_or_create_edit_group()
+ return redirect('/editgroup/{}'.format(eg.id))
+
### Static Routes ###########################################################
diff --git a/fatcat/templates/editgroup_view.html b/fatcat/templates/editgroup_view.html
new file mode 100644
index 00000000..13eb2d7f
--- /dev/null
+++ b/fatcat/templates/editgroup_view.html
@@ -0,0 +1,15 @@
+{% extends "base.html" %}
+{% block body %}
+
+<h1>Edit Group: {{ editgroup.id}}</h1>
+
+ description = db.Column(db.String)
+ editor = db.relationship('Editor', foreign_keys='EditGroup.editor_id')
+
+
+<p>Editor: <a href="/editor/{{ editgroup.editor.id }}">{{ editgroup.editor.username }}</a>
+<p>Description: {{ editgroup.description }}
+
+<p>TODO: list edits by type...</p>
+
+{% endblock %}
diff --git a/tests/routes.py b/tests/routes.py
index 194dc865..49afc5ce 100644
--- a/tests/routes.py
+++ b/tests/routes.py
@@ -29,3 +29,6 @@ def test_all_views(rich_app):
rv = app.get('/v0/work/random')
rv = app.get(rv.location)
assert rv.status_code == 200
+
+ rv = app.get('/editgroup/1')
+ assert rv.status_code == 200