From be4ce024f494337c36e0ce29b844071573471650 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Fri, 6 Oct 2017 00:13:22 +0200 Subject: [PATCH] Introducing public and private extension_props for users - public: they will be visible to the world (for example as result of the User.find() query) - private: visible only to their user --- pillar/api/eve_settings.py | 16 +++++++++++----- pillar/api/users/hooks.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pillar/api/eve_settings.py b/pillar/api/eve_settings.py index 4c2adc11..2e6aeaa0 100644 --- a/pillar/api/eve_settings.py +++ b/pillar/api/eve_settings.py @@ -129,11 +129,17 @@ users_schema = { } }, - # Properties defined by extensions. Extensions should use their name - # (see the PillarExtension.name property) as the key, and are free to - # use whatever they want as value (but we suggest a dict for future - # extendability). - 'extension_props': { + # Properties defined by extensions. Extensions should use their name (see the + # PillarExtension.name property) as the key, and are free to use whatever they want as value, + # but we suggest a dict for future extendability. + # Properties can be of two types: + # - public: they will be visible to the world (for example as part of the User.find() query) + # - private: visible only to their user + 'extension_props_public': { + 'type': 'dict', + 'required': False, + }, + 'extension_props_private': { 'type': 'dict', 'required': False, }, diff --git a/pillar/api/users/hooks.py b/pillar/api/users/hooks.py index bda38208..46e4ef9a 100644 --- a/pillar/api/users/hooks.py +++ b/pillar/api/users/hooks.py @@ -135,7 +135,7 @@ def after_fetching_user(user): return # Remove all fields except public ones. - public_fields = {'full_name', 'username', 'email'} + public_fields = {'full_name', 'username', 'email', 'extension_props_public'} for field in list(user.keys()): if field not in public_fields: del user[field]