From 1593e5c09d32513ce054a46ae02169ca52c6c23d Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Tue, 15 Mar 2016 10:20:28 +0100 Subject: [PATCH] Update to config.py.example --- pillar/application/__init__.py | 6 ++---- pillar/application/utils/activities.py | 12 +++--------- pillar/application/utils/authentication.py | 2 +- pillar/config.py.example | 4 +++- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pillar/application/__init__.py b/pillar/application/__init__.py index 0dc21d97..35f4be95 100644 --- a/pillar/application/__init__.py +++ b/pillar/application/__init__.py @@ -110,16 +110,14 @@ try: os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = \ app.config['GCLOUD_APP_CREDENTIALS'] except KeyError: - raise SystemExit('GOOGLE_APPLICATION_CREDENTIALS configuration is missing') + raise SystemExit('GCLOUD_APP_CREDENTIALS configuration is missing') # Storage backend (GCS) try: - os.environ['GCLOUD_PROJECT'] = \ - app.config['GCLOUD_PROJECT'] + os.environ['GCLOUD_PROJECT'] = app.config['GCLOUD_PROJECT'] except KeyError: raise SystemExit('GCLOUD_PROJECT configuration value is missing') - # Algolia search if 'ALGOLIA_USER' in app.config: client = algoliasearch.Client( diff --git a/pillar/application/utils/activities.py b/pillar/application/utils/activities.py index 6eacf2a5..1871ddc8 100644 --- a/pillar/application/utils/activities.py +++ b/pillar/application/utils/activities.py @@ -6,15 +6,11 @@ def notification_parse(notification): # notification = dict(a='n') # TODO: finish fixing this activities_collection = app.data.driver.db['activities'] - activities_subscriptions_collection = app.data.driver.db['activities-subscriptions'] + activities_subscriptions_collection = \ + app.data.driver.db['activities-subscriptions'] users_collection = app.data.driver.db['users'] nodes_collection = app.data.driver.db['nodes'] activity = activities_collection.find_one({'_id': notification['activity']}) - # actor = users_collection.find_one({'_id': activity['actor_user']}) - # Context is optional - context_object_type = None - context_object_name = None - context_object_url = None if activity['object_type'] != 'node': return @@ -30,11 +26,10 @@ def notification_parse(notification): if node['parent']['user'] == g.current_user['user_id']: owner = "your {0}".format(node['parent']['node_type']) else: - parent_comment_user = users_collection.find_one( {'_id': node['parent']['user']}) owner = "{0}'s {1}".format(parent_comment_user['username'], - node['parent']['node_type']) + node['parent']['node_type']) context_object_type = node['parent']['node_type'] context_object_name = owner @@ -51,7 +46,6 @@ def notification_parse(notification): 'context_object_type': 'node', 'context_object': context_object_id, } - subscription = activities_subscriptions_collection.find_one(lookup) if subscription and subscription['notifications']['web'] == True: is_subscribed = True diff --git a/pillar/application/utils/authentication.py b/pillar/application/utils/authentication.py index 40173eb5..1251543f 100644 --- a/pillar/application/utils/authentication.py +++ b/pillar/application/utils/authentication.py @@ -56,7 +56,7 @@ def validate_token(): flask.g object, so that permissions and access to a resource can be defined from it. - When the token is succesfully validated, sets `g.current_user` to contain + When the token is successfully validated, sets `g.current_user` to contain the user information. @returns True iff the user is logged in with a valid Blender ID token. diff --git a/pillar/config.py.example b/pillar/config.py.example index e37ab90f..0b783532 100644 --- a/pillar/config.py.example +++ b/pillar/config.py.example @@ -25,8 +25,10 @@ class Development(object): # Credentials to access project on the Google Cloud where Google Cloud # Storage is enabled (Pillar will automatically create and manage buckets) - GOOGLE_APPLICATION_CREDENTIALS = os.environ.get( + GCLOUD_APP_CREDENTIALS = os.environ.get( 'GOOGLE_APPLICATION_CREDENTIALS', '/data/config/google_app.json') + GCLOUD_PROJECT = os.environ.get('GCLOUD_PROJECT', 'blender-cloud') + # Fill in only if we plan to sign our urls using a the CDN CDN_USE_URL_SIGNING = False