From 2be41a7145ccf105dc0c367e7f8869c2f69eeed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 12 Sep 2018 15:58:29 +0200 Subject: [PATCH] Show author badges on assets and comments Comments layout is still broken, marked as TODO(Pablo). --- pillar/api/users/hooks.py | 2 +- pillar/web/subquery.py | 3 ++- src/styles/_project.sass | 18 ++++++++++++++++++ src/templates/nodes/custom/comment/_macros.pug | 3 +++ src/templates/nodes/view_base.pug | 1 + 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pillar/api/users/hooks.py b/pillar/api/users/hooks.py index 49c91b70..95154f6e 100644 --- a/pillar/api/users/hooks.py +++ b/pillar/api/users/hooks.py @@ -142,7 +142,7 @@ def after_fetching_user(user): return # Remove all fields except public ones. - public_fields = {'full_name', 'username', 'email', 'extension_props_public'} + public_fields = {'full_name', 'username', 'email', 'extension_props_public', 'badges'} for field in list(user.keys()): if field not in public_fields: del user[field] diff --git a/pillar/web/subquery.py b/pillar/web/subquery.py index bde086c5..aebc659e 100644 --- a/pillar/web/subquery.py +++ b/pillar/web/subquery.py @@ -33,7 +33,8 @@ def get_user_info(user_id): # TODO: put those fields into a config var or module-level global. return {'email': user.email, 'full_name': user.full_name, - 'username': user.username} + 'username': user.username, + 'badges_html': (user.badges and user.badges.html) or ''} def setup_app(app): diff --git a/src/styles/_project.sass b/src/styles/_project.sass index 40865d14..4ff4690a 100644 --- a/src/styles/_project.sass +++ b/src/styles/_project.sass @@ -754,6 +754,24 @@ section.node-details-container &.status color: $color-text-dark + ul.blender-id-badges + padding-left: 0 + list-style-type: none + display: flex + + > li + margin: 0 + padding: 0 + + > a + display: block + padding: 2px + + img + // TODO(Pablo): fix this so that it keeps the aspect ratio okay when the original image isn't square. + max-width: 16px + max-height: 16px + .node-details-license color: $color-text-dark-secondary &:hover diff --git a/src/templates/nodes/custom/comment/_macros.pug b/src/templates/nodes/custom/comment/_macros.pug index 3768a9dd..70c04929 100644 --- a/src/templates/nodes/custom/comment/_macros.pug +++ b/src/templates/nodes/custom/comment/_macros.pug @@ -10,6 +10,9 @@ .comment-content .comment-body p.comment-author {{ comment._user.full_name }} + //- TODO(Pablo): due to the broad styling done on the .comment-content class the + //- styling for the badges that I put in _project.sass isn't applied properly here. + | {{ comment._user.badges_html|safe }} span {{comment.properties | markdowned('content') }} diff --git a/src/templates/nodes/view_base.pug b/src/templates/nodes/view_base.pug index 7f9ae74e..67535f96 100644 --- a/src/templates/nodes/view_base.pug +++ b/src/templates/nodes/view_base.pug @@ -47,6 +47,7 @@ li(title="Author") | {{ node.user.full_name }} + | {{ node.user.badges.html|safe }} li( title="Created {{ node._created }} (updated {{ node._updated | pretty_date_time }})")