From 74e29b596294049a375f7ed8c0f54a987856f8a7 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 25 Apr 2018 16:11:38 -0700 Subject: improve editgroup view --- fatcat/api.py | 14 +++++++++++-- fatcat/templates/editgroup_view.html | 40 +++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/fatcat/api.py b/fatcat/api.py index eaf45d77..2c91533b 100644 --- a/fatcat/api.py +++ b/fatcat/api.py @@ -231,8 +231,18 @@ def api_editgroup_get(ident): .join(EditGroup.editor)\ .filter(EditGroup.id==ident)\ .first_or_404() - # XXX: fill in all the related edit types... - return editgroup_schema.jsonify(entity) + rv = editgroup_schema.dump(entity).data + rv['work_edits'] = work_edit_schema.dump( + WorkEdit.query.filter(EditGroup.id==ident).all(), many=True).data + rv['release_edits'] = release_edit_schema.dump( + ReleaseEdit.query.filter(EditGroup.id==ident).all(), many=True).data + rv['creator_edits'] = creator_edit_schema.dump( + CreatorEdit.query.filter(EditGroup.id==ident).all(), many=True).data + rv['container_edits'] = container_edit_schema.dump( + ContainerEdit.query.filter(EditGroup.id==ident).all(), many=True).data + rv['file_edits'] = file_edit_schema.dump( + FileEdit.query.filter(EditGroup.id==ident).all(), many=True).data + return jsonify(rv) @app.route('/v0/editgroup', methods=['POST']) def api_editgroup_create(params=None): diff --git a/fatcat/templates/editgroup_view.html b/fatcat/templates/editgroup_view.html index 144c9502..4ed08501 100644 --- a/fatcat/templates/editgroup_view.html +++ b/fatcat/templates/editgroup_view.html @@ -6,6 +6,44 @@

Editor: {{ editgroup.editor.username }}

Description: {{ editgroup.description }} -

TODO: list edits by type...

+

Work Edits ({{ editgroup.work_edits|count }})

+ + +

Release Edits ({{ editgroup.release_edits|count }})

+ + +

Container Edits ({{ editgroup.container_edits|count }})

+ + +

Creator Edits ({{ editgroup.creator_edits|count }})

+ + +

File Edits ({{ editgroup.file_edits|count }})

+ {% endblock %} -- cgit v1.2.3