Blame alembic/versions/21292448a775_update_acls_descriptions.py

Pierre-Yves Chibon f92c79
"""Update ACLs descriptions
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
Revision ID: 21292448a775
Pierre-Yves Chibon f92c79
Revises: 3237fc64b306
Pierre-Yves Chibon f92c79
Create Date: 2017-10-12 16:55:05.066340
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
"""
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
# revision identifiers, used by Alembic.
Pierre-Yves Chibon f92c79
revision = '21292448a775'
Pierre-Yves Chibon f92c79
down_revision = '3237fc64b306'
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
from alembic import op
Pierre-Yves Chibon f92c79
import sqlalchemy as sa
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
ACLS = {
Pierre-Yves Chibon f92c79
    'create_project': 'Create a new project',
Pierre-Yves Chibon f92c79
    'fork_project': 'Fork a project',
Pierre-Yves Chibon f92c79
    'issue_assign': 'Assign issue to someone',
Pierre-Yves Chibon f92c79
    'issue_create': 'Create a new ticket',
Pierre-Yves Chibon f92c79
    'issue_change_status': 'Change the status of a ticket',
Pierre-Yves Chibon f92c79
    'issue_comment': 'Comment on a ticket',
Pierre-Yves Chibon f92c79
    'pull_request_close': 'Close a pull-request',
Pierre-Yves Chibon f92c79
    'pull_request_comment': 'Comment on a pull-request',
Pierre-Yves Chibon f92c79
    'pull_request_flag': 'Flag a pull-request',
Pierre-Yves Chibon f92c79
    'pull_request_merge': 'Merge a pull-request',
Pierre-Yves Chibon f92c79
    'issue_subscribe': 'Subscribe the user with this token to an issue',
Pierre-Yves Chibon f92c79
    'issue_update': 'Update an issue, status, comments, custom fields...',
Pierre-Yves Chibon f92c79
    'issue_update_custom_fields': 'Update the custom fields of an issue',
Pierre-Yves Chibon f92c79
    'issue_update_milestone': 'Update the milestone of an issue',
Pierre-Yves Chibon f92c79
    'modify_project': 'Modify an existing project',
Pierre-Yves Chibon f92c79
    'generate_acls_project': 'Generate the Gitolite ACLs on a project'
Pierre-Yves Chibon f92c79
}
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
def upgrade():
Pierre-Yves Chibon f92c79
    """ Update the ACLs description stored in the database to be more
Pierre-Yves Chibon f92c79
    generic.
Pierre-Yves Chibon f92c79
    """
Pierre-Yves Chibon f92c79
    for acl in ACLS:
Pierre-Yves Chibon f92c79
        op.execute(
Pierre-Yves Chibon f92c79
            "UPDATE acls SET description='%s' WHERE name='%s';" % (
Pierre-Yves Chibon f92c79
                ACLS[acl], acl)
Pierre-Yves Chibon f92c79
        )
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
Pierre-Yves Chibon f92c79
def downgrade():
Pierre-Yves Chibon f92c79
    """ There isn't really anything to back out, so just keep going. """
Pierre-Yves Chibon f92c79
    pass