From 2688e18228e15558c99f1372f003ca95e7be4523 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 23 Apr 2018 19:37:36 -0700 Subject: editgroup view --- fatcat/api.py | 2 +- fatcat/models.py | 1 + fatcat/routes.py | 14 ++++++++++++++ fatcat/templates/editgroup_view.html | 15 +++++++++++++++ tests/routes.py | 3 +++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 fatcat/templates/editgroup_view.html 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/', 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/', 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 %} + +

Edit Group: {{ editgroup.id}}

+ + description = db.Column(db.String) + editor = db.relationship('Editor', foreign_keys='EditGroup.editor_id') + + +

Editor: {{ editgroup.editor.username }} +

Description: {{ editgroup.description }} + +

TODO: list edits by type...

+ +{% 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 -- cgit v1.2.3