From f92c797ebb179825e6f935eb641ff80f7f1d32e8 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 12 2017 15:36:35 +0000 Subject: Generalize the description of the ACLs Now that we can have project-less API token, having ACLs that say `in this project` is confusing. This commits generalize the descriptions of the ACLs and add an alembic migration script that updates existing records. Fixes https://pagure.io/pagure/issue/2441 Signed-off-by: Pierre-Yves Chibon --- diff --git a/alembic/versions/21292448a775_update_acls_descriptions.py b/alembic/versions/21292448a775_update_acls_descriptions.py new file mode 100644 index 0000000..fea3de8 --- /dev/null +++ b/alembic/versions/21292448a775_update_acls_descriptions.py @@ -0,0 +1,48 @@ +"""Update ACLs descriptions + +Revision ID: 21292448a775 +Revises: 3237fc64b306 +Create Date: 2017-10-12 16:55:05.066340 + +""" + +# revision identifiers, used by Alembic. +revision = '21292448a775' +down_revision = '3237fc64b306' + +from alembic import op +import sqlalchemy as sa + +ACLS = { + 'create_project': 'Create a new project', + 'fork_project': 'Fork a project', + 'issue_assign': 'Assign issue to someone', + 'issue_create': 'Create a new ticket', + 'issue_change_status': 'Change the status of a ticket', + 'issue_comment': 'Comment on a ticket', + 'pull_request_close': 'Close a pull-request', + 'pull_request_comment': 'Comment on a pull-request', + 'pull_request_flag': 'Flag a pull-request', + 'pull_request_merge': 'Merge a pull-request', + 'issue_subscribe': 'Subscribe the user with this token to an issue', + 'issue_update': 'Update an issue, status, comments, custom fields...', + 'issue_update_custom_fields': 'Update the custom fields of an issue', + 'issue_update_milestone': 'Update the milestone of an issue', + 'modify_project': 'Modify an existing project', + 'generate_acls_project': 'Generate the Gitolite ACLs on a project' +} + +def upgrade(): + """ Update the ACLs description stored in the database to be more + generic. + """ + for acl in ACLS: + op.execute( + "UPDATE acls SET description='%s' WHERE name='%s';" % ( + ACLS[acl], acl) + ) + + +def downgrade(): + """ There isn't really anything to back out, so just keep going. """ + pass diff --git a/pagure/default_config.py b/pagure/default_config.py index c82da8c..f2e1bb1 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -250,13 +250,13 @@ ACLS = { 'create_project': 'Create a new project', 'fork_project': 'Fork a project', 'issue_assign': 'Assign issue to someone', - 'issue_create': 'Create a new ticket against this project', - 'issue_change_status': 'Change the status of a ticket of this project', - 'issue_comment': 'Comment on a ticket of this project', - 'pull_request_close': 'Close a pull-request of this project', - 'pull_request_comment': 'Comment on a pull-request of this project', - 'pull_request_flag': 'Flag a pull-request of this project', - 'pull_request_merge': 'Merge a pull-request of this project', + 'issue_create': 'Create a new ticket', + 'issue_change_status': 'Change the status of a ticket', + 'issue_comment': 'Comment on a ticket', + 'pull_request_close': 'Close a pull-request', + 'pull_request_comment': 'Comment on a pull-request', + 'pull_request_flag': 'Flag a pull-request', + 'pull_request_merge': 'Merge a pull-request', 'issue_subscribe': 'Subscribe the user with this token to an issue', 'issue_update': 'Update an issue, status, comments, custom fields...', 'issue_update_custom_fields': 'Update the custom fields of an issue',