From e7ad9a390584ac9df0f7c03dc687e38ca4e073e3 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 17 Nov 2021 20:23:30 -0800 Subject: initial implementation of editgroup 'diff' for review --- python/fatcat_web/routes.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'python/fatcat_web/routes.py') diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 3d2c68cd..f180e339 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -41,6 +41,7 @@ from fatcat_web.auth import ( ) from fatcat_web.cors import crossdomain from fatcat_web.entity_helpers import ( + editgroup_get_diffs, generic_get_editgroup_entity, generic_get_entity, generic_get_entity_revision, @@ -689,6 +690,35 @@ def editgroup_view(ident: str) -> AnyResponse: return render_template("editgroup_view.html", editgroup=eg, auth_to=auth_to) +@app.route("/editgroup//diff", methods=["GET"]) +def editgroup_diff_view(ident: str) -> AnyResponse: + try: + eg = api.get_editgroup(str(ident)) + eg.editor = api.get_editor(eg.editor_id) + eg.annotations = api.get_editgroup_annotations(eg.editgroup_id, expand="editors") + except ApiException as ae: + abort(ae.status) + # TODO: idomatic check for login? + auth_to = dict( + submit=False, + accept=False, + edit=False, + annotate=False, + ) + if session.get("editor"): + user = load_user(session["editor"]["editor_id"]) + auth_to["annotate"] = True + if user.is_admin or user.editor_id == eg.editor_id: + auth_to["submit"] = True + auth_to["edit"] = True + if user.is_admin: + auth_to["accept"] = True + diffs = editgroup_get_diffs(eg) + return render_template( + "editgroup_diff.html", editgroup=eg, auth_to=auth_to, editgroup_diffs=diffs + ) + + @app.route("/editgroup//annotation", methods=["POST"]) @login_required def editgroup_create_annotation(ident: str) -> AnyResponse: -- cgit v1.2.3