Move Table with confirm

This commit is contained in:
Amritanshu
2019-08-10 14:21:40 +05:30
parent 4fb8d9118e
commit 2fcff26e34
12 changed files with 248 additions and 33 deletions

View File

@ -368,7 +368,6 @@ def includeme(config):
config.add_route("merge_table", "/MergeTable.json")
config.add_route("move_kot", "/MoveKot.json")
config.add_route("move_table", "/MoveTable.json")
config.add_route("permission_list", "/Permissions.json")

View File

@ -6,64 +6,98 @@ from pyramid.view import view_config
from barker.models import Kot, Voucher, Overview
@view_config(request_method='POST', route_name='merge_kot', renderer='json', permission='Merge Kots', trans=True)
@view_config(
request_method="POST",
route_name="merge_kot",
renderer="json",
permission="Merge Kots",
trans=True,
)
def merge_kot(request):
json = request.json_body
kot_id = uuid.UUID(json['KotID'])
voucher_id = uuid.UUID(json['NewVoucherID'])
kot_id = uuid.UUID(json["KotID"])
voucher_id = uuid.UUID(json["NewVoucherID"])
request.dbsession.query(Kot).filter(Kot.id == kot_id).update({Kot.voucher_id: voucher_id})
request.dbsession.query(Kot).filter(Kot.id == kot_id).update(
{Kot.voucher_id: voucher_id}
)
transaction.commit()
return voucher_id
@view_config(request_method='POST', route_name='move_kot', renderer='json', permission='Move Kot', trans=True)
@view_config(
request_method="POST",
route_name="move_kot",
renderer="json",
permission="Move Kot",
trans=True,
)
def move_kot(request):
json = request.json_body
kot_id = uuid.UUID(json['KotID'])
food_table_id = uuid.UUID(json['FoodTableID'])
kot_id = uuid.UUID(json["KotID"])
food_table_id = uuid.UUID(json["FoodTableID"])
kot = request.dbsession.query(Kot).filter(Kot.id == kot_id).first()
item = Voucher(kot.voucher.pax, food_table_id, kot.voucher.customer_id, False, kot.voucher.voucher_type,
kot.voucher.user_id, request.dbsession)
item = Voucher(
kot.voucher.pax,
food_table_id,
kot.voucher.customer_id,
False,
kot.voucher.voucher_type,
kot.voucher.user_id,
request.dbsession,
)
request.dbsession.add(item)
item.kots.append(kot)
status = "printed" if item.is_printed else "running"
item.status = Overview(voucher_id=None, food_table_id=item.food_table_id, status=status)
item.status = Overview(
voucher_id=None, food_table_id=item.food_table_id, status=status
)
request.dbsession.add(item.status)
transaction.commit()
return item.id
@view_config(request_method='POST', route_name='move_table', renderer='json', permission='Move Table', trans=True)
@view_config(
request_method="POST",
route_name="v1_vouchers_id",
request_param="m",
renderer="json",
permission="Move Table",
trans=True,
)
def move_table(request):
json = request.json_body
voucher_id = uuid.UUID(json['VoucherID'])
food_table_id = uuid.UUID(json['FoodTableID'])
id_ = uuid.UUID(request.matchdict["id"])
table_id = uuid.UUID(request.GET["m"])
request.dbsession.query(
Overview
).filter(
Overview.voucher_id == voucher_id
).update({Overview.food_table_id: food_table_id})
request.dbsession.query(Overview).filter(Overview.voucher_id == id_).update(
{Overview.food_table_id: table_id}
)
request.dbsession.query(
Voucher
).filter(
Voucher.id == voucher_id
).update({Voucher.food_table_id: food_table_id})
request.dbsession.query(Voucher).filter(Voucher.id == id_).update(
{Voucher.food_table_id: table_id}
)
transaction.commit()
return True
@view_config(request_method='POST', route_name='merge_table', renderer='json', permission='Merge Tables', trans=True)
@view_config(
request_method="POST",
route_name="merge_table",
renderer="json",
permission="Merge Tables",
trans=True,
)
def merge_table(request):
json = request.json_body
voucher_id = uuid.UUID(json['VoucherID'])
new_voucher_id = uuid.UUID(json['NewVoucherID'])
voucher_id = uuid.UUID(json["VoucherID"])
new_voucher_id = uuid.UUID(json["NewVoucherID"])
request.dbsession.query(Kot).filter(Kot.voucher_id == voucher_id).update({Kot.voucher_id: new_voucher_id})
request.dbsession.query(Kot).filter(Kot.voucher_id == voucher_id).update(
{Kot.voucher_id: new_voucher_id}
)
request.dbsession.query(Voucher).filter(Voucher.id == voucher_id).delete()
transaction.commit()
return voucher_id