mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Manage template permission added. All tests passing.
This commit is contained in:
36
migrations/versions/0030_add_template_permission.py
Normal file
36
migrations/versions/0030_add_template_permission.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0030_add_template_permission
|
||||
Revises: 0029_add_permissions_to_invite
|
||||
Create Date: 2016-02-26 10:33:20.536362
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0030_add_template_permission'
|
||||
down_revision = '0029_add_permissions_to_invite'
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
user_services = conn.execute("SELECT * FROM user_to_service").fetchall()
|
||||
for entry in user_services:
|
||||
id_ = uuid.uuid4()
|
||||
created_at = datetime.now().isoformat().replace('T', ' ')
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', 'manage_templates', '{}')").format(id_, entry[0], entry[1], created_at))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("DELETE FROM permissions where permission='manage_templates")
|
||||
|
||||
### end Alembic commands ###
|
||||
Reference in New Issue
Block a user