diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-17 20:23:30 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-17 20:23:45 -0800 |
commit | e7ad9a390584ac9df0f7c03dc687e38ca4e073e3 (patch) | |
tree | fd76555d10028d03c153cbd761bc217fa524d123 /python/fatcat_web/routes.py | |
parent | 3497282bbb6db33aac9fd43d2a22177c6ac24978 (diff) | |
download | fatcat-e7ad9a390584ac9df0f7c03dc687e38ca4e073e3.tar.gz fatcat-e7ad9a390584ac9df0f7c03dc687e38ca4e073e3.zip |
initial implementation of editgroup 'diff' for review
Diffstat (limited to 'python/fatcat_web/routes.py')
-rw-r--r-- | python/fatcat_web/routes.py | 30 |
1 files changed, 30 insertions, 0 deletions
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/<string(length=26):ident>/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/<string(length=26):ident>/annotation", methods=["POST"]) @login_required def editgroup_create_annotation(ident: str) -> AnyResponse: |