From 1c9f425a4003e5a97854c825a751863e67576ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 23 Aug 2017 16:04:24 +0200 Subject: [PATCH] Orgs: use flask_login.current_user to avoid calling current_user() all the time --- pillar/web/organizations/routes.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pillar/web/organizations/routes.py b/pillar/web/organizations/routes.py index 21bed490..4b86f16e 100644 --- a/pillar/web/organizations/routes.py +++ b/pillar/web/organizations/routes.py @@ -1,17 +1,13 @@ import logging -import attr from flask import Blueprint, render_template, request, jsonify import flask_wtf.csrf -import werkzeug.exceptions as wz_exceptions - -from pillarsdk import User +from flask_login import current_user import pillar.flask_extra from pillar import current_app from pillar.api.utils import authorization, str2id, gravatar from pillar.web.system_util import pillar_api -from pillar.api.utils.authentication import current_user from pillarsdk import Organization @@ -29,7 +25,7 @@ def index(organization_id: str = None): if not organization_id and organizations['_items']: organization_id = organizations['_items'][0]._id - can_create_organization = current_user().has_cap('create-organization') + can_create_organization = current_user.has_cap('create-organization') return render_template('organizations/index.html', can_create_organization=can_create_organization, @@ -75,7 +71,7 @@ def view_embed(organization_id: str): def create_new(): """Creates a new Organization, owned by the currently logged-in user.""" - user_id = current_user().user_id + user_id = current_user.user_id log.info('Creating new organization for user %s', user_id) name = request.form['name']