Simplified some permissions

Renamed Accounts Audit to Audit
Renamed Machines to Devices as it made sense
Sections and Tables are now under Sections Permission
Guest Book is now under Customers Permission
Renamed Beer Consumption Report to Beer Sale Report
Fix: Move Kot and Table to check what the final effect is
This commit is contained in:
2020-11-15 12:26:24 +05:30
parent aead1f1b36
commit 163b40e9e5
44 changed files with 310 additions and 253 deletions

View File

@ -99,6 +99,66 @@ def add_all_roles_to_owner():
)
def rename_permissions():
p = table(
"permissions",
column("id", postgresql.UUID(as_uuid=True)),
column("name", sa.Unicode(length=255)),
)
rp = table(
"role_permissions",
column("id", postgresql.UUID(as_uuid=True)),
column("permission_id", postgresql.UUID(as_uuid=True)),
column("role_id", postgresql.UUID(as_uuid=True)),
)
op.execute(p.update().where(p.c.name == "Accounts Audit").values(name="Audit"))
op.execute(p.update().where(p.c.name == "Beer Consumption").values(name="Beer Sale Report"))
op.execute(p.update().where(p.c.name == "Bill Details").values(name="Bill Settlement Report"))
op.execute(p.update().where(p.c.name == "Cashier Checkout").values(name="Cashier Report"))
op.execute(p.update().where(p.c.name == "Sales Detail").values(name="Product Sale Report"))
op.execute(p.update().where(p.c.name == "Sales Analysis").values(name="Sale Report"))
op.execute(p.update().where(p.c.name == "Tax Analysis").values(name="Tax Report"))
op.execute(p.update().where(p.c.name == "Machines").values(name="Devices"))
op.execute(p.update().where(p.c.name == "Tables").values(name="Sections"))
op.execute(
rp.delete().where(
rp.c.permission_id == select([p.c.id]).where(p.c.name.ilike("Void or Reprinted Bill Report")).as_scalar()
)
)
op.execute(rp.delete().where(rp.c.permission_id == select([p.c.id]).where(p.c.name.ilike("Roles")).as_scalar()))
op.execute(
rp.delete().where(rp.c.permission_id == select([p.c.id]).where(p.c.name.ilike("NC Product")).as_scalar())
)
op.execute(
rp.delete().where(rp.c.permission_id == select([p.c.id]).where(p.c.name.ilike("Change Rate")).as_scalar())
)
op.execute(p.delete().where(p.c.name == "Void or Reprinted Bill Report"))
op.execute(p.delete().where(p.c.name == "Roles"))
op.execute(p.delete().where(p.c.name == "NC Product"))
op.execute(p.delete().where(p.c.name == "Change Rate"))
def update_settlements():
s = table(
"settlements",
column("voucher_id", postgresql.UUID(as_uuid=True)),
column("settled", sa.Integer()),
)
v = table(
"vouchers",
sa.Column("id", postgresql.UUID(as_uuid=True)),
sa.Column("voucher_type", sa.Integer()),
)
op.execute(
s.update()
.values(settled=9)
.where(s.c.voucher_id == v.c.id)
.where(v.c.voucher_type == 5)
.where(s.c.settled == 1)
)
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
update_sale_categories()
@ -182,7 +242,9 @@ def upgrade():
(prod.c.units, "="),
(func.daterange(prod.c.valid_from, prod.c.valid_till, text("'[]'")), "&&"),
)
rename_permissions()
add_all_roles_to_owner()
update_settlements()
# ### end Alembic commands ###

View File

@ -468,11 +468,8 @@ def upgrade():
),
)
op.execute(Permission.__table__.insert().values(id="7669dfc9-cc75-4e48-b267-145c8832a83c", name="Guest Book"))
op.execute(Permission.__table__.insert().values(id="5b66c6f6-003a-4ef8-ba28-49b8ff1ac33c", name="Printers"))
op.execute(Permission.__table__.insert().values(id="c973f32c-a37b-496a-8dc5-60d2e4c39e97", name="Sections"))
op.execute(Permission.__table__.insert().values(id="7a04ba63-5d08-4078-9051-a6d91cce3e48", name="Section Printers"))
op.execute(Permission.__table__.insert().values(id="d4e1d14f-f2c2-4728-9303-a0d8c74c5ea1", name="Devices"))
op.execute(Permission.__table__.insert().values(id="5f6110ba-2d3a-41cb-9597-1157774f10cb", name="Add Devices"))
op.execute(
Section.__table__.insert().values(id="3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df", name="Main", is_fixture=True)