Make ROLES_FOR_COMMENT_VOTING a config value

This way we can override it when extending Pillar for other projects that might not require the 'subscriber' or 'demo' roles.
This commit is contained in:
Francesco Siddi 2017-05-28 19:04:11 +02:00
parent 85922f4493
commit add1c8b9b3
2 changed files with 2 additions and 2 deletions

View File

@ -10,7 +10,6 @@ from pillar.api.utils import authorization, authentication, jsonify
from . import register_patch_handler
log = logging.getLogger(__name__)
ROLES_FOR_COMMENT_VOTING = {'subscriber', 'demo'}
COMMENT_VOTING_OPS = {'upvote', 'downvote', 'revoke'}
VALID_COMMENT_OPERATIONS = COMMENT_VOTING_OPS.union({'edit'})
@ -180,7 +179,7 @@ def assert_is_valid_patch(node_id, patch):
return
# See whether the user is allowed to patch
if authorization.user_matches_roles(ROLES_FOR_COMMENT_VOTING):
if authorization.user_matches_roles(current_app.config['ROLES_FOR_COMMENT_VOTING']):
log.debug('User is allowed to upvote/downvote comment')
return

View File

@ -125,6 +125,7 @@ FILESIZE_LIMIT_BYTES_NONSUBS = 32 * 2 ** 20
# Unless they have one of those roles.
ROLES_FOR_UNLIMITED_UPLOADS = {'subscriber', 'demo', 'admin'}
ROLES_FOR_COMMENT_VOTING = {'subscriber', 'demo'}
#############################################
# Old pillar-web config: