mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Merge pull request #3284 from alphagov/update-bcast-permissions-data
Remove original permissions from broadcast users
This commit is contained in:
32
migrations/versions/0361_new_user_bcast_permissions.py
Normal file
32
migrations/versions/0361_new_user_bcast_permissions.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
"""
|
||||||
|
|
||||||
|
Revision ID: 0361_new_user_bcast_permissions
|
||||||
|
Revises: 0360_remove_sched_notifications
|
||||||
|
Create Date: 2021-06-30 11:42:32.780734
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
revision = '0361_new_user_bcast_permissions'
|
||||||
|
down_revision = '0360_remove_sched_notifications'
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
"""
|
||||||
|
Delete all permissions for broadcast service users and invited pending users, apart from 'view_activity'
|
||||||
|
which they always have.
|
||||||
|
"""
|
||||||
|
op.execute(
|
||||||
|
"DELETE FROM permissions WHERE permission != 'view_activity' "
|
||||||
|
"and service_id in (select id from services where organisation_id = '38e4bf69-93b0-445d-acee-53ea53fe02df')"
|
||||||
|
)
|
||||||
|
op.execute(
|
||||||
|
"UPDATE invited_users SET permissions = 'view_activity' WHERE status = 'pending' "
|
||||||
|
"and service_id in (select id from services where organisation_id = '38e4bf69-93b0-445d-acee-53ea53fe02df')"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
"""
|
||||||
|
This change cannot be downgraded since we no longer have access to the original permissions users had.
|
||||||
|
"""
|
||||||
Reference in New Issue
Block a user