Added routes for serving index.html for various routes.
Depreciated: Customers TODO: Reprint, Setting, Change (ie. voucher void and reprint)
This commit is contained in:
parent
461db9d8fa
commit
ee54e36dda
144
barker/routes.py
144
barker/routes.py
@ -47,7 +47,7 @@ def includeme(config):
|
|||||||
request_method="GET",
|
request_method="GET",
|
||||||
permission="Guest Book",
|
permission="Guest Book",
|
||||||
)
|
)
|
||||||
config.add_route("guest_book_list", "/guest-book/list")
|
config.add_route("guest_book_list", "/guest-book")
|
||||||
config.add_view(
|
config.add_view(
|
||||||
"barker.views.home",
|
"barker.views.home",
|
||||||
route_name="guest_book_list",
|
route_name="guest_book_list",
|
||||||
@ -350,57 +350,133 @@ def includeme(config):
|
|||||||
config.add_route("v1_vouchers_new", "/v1/vouchers/new")
|
config.add_route("v1_vouchers_new", "/v1/vouchers/new")
|
||||||
config.add_route("v1_vouchers_id", "/v1/vouchers/{id}")
|
config.add_route("v1_vouchers_id", "/v1/vouchers/{id}")
|
||||||
|
|
||||||
|
config.add_route("sales", "/sales")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="sales",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Authenticated",
|
||||||
|
)
|
||||||
|
config.add_route("sales_catch", "/sales/*rest")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="sales_catch",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Authenticated",
|
||||||
|
)
|
||||||
|
|
||||||
config.add_route("v1_move_table", "/v1/move-table")
|
config.add_route("v1_move_table", "/v1/move-table")
|
||||||
config.add_route("v1_move_kot", "/v1/move-kot")
|
config.add_route("v1_move_kot", "/v1/move-kot")
|
||||||
|
|
||||||
config.add_route("v1_active_cashiers", "/v1/active-cashiers")
|
config.add_route("v1_active_cashiers", "/v1/active-cashiers")
|
||||||
config.add_route("v1_checkout_id", "/v1/checkout/{id}")
|
config.add_route("v1_checkout_id", "/v1/checkout/{id}")
|
||||||
|
config.add_route("checkout_id", "/checkout/{id}")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="checkout_id",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Cashier Checkout",
|
||||||
|
)
|
||||||
config.add_route("v1_checkout_blank", "/v1/checkout")
|
config.add_route("v1_checkout_blank", "/v1/checkout")
|
||||||
|
config.add_route("checkout_blank", "/checkout")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="checkout_blank",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Cashier Checkout",
|
||||||
|
)
|
||||||
|
|
||||||
config.add_route("v1_sa_sale", "/v1/sale-analysis/sale")
|
config.add_route("v1_sa_sale", "/v1/sale-analysis/sale")
|
||||||
config.add_route("v1_sa_settlements", "/v1/sale-analysis/settlements")
|
config.add_route("v1_sa_settlements", "/v1/sale-analysis/settlements")
|
||||||
config.add_route("v1_sa_tax", "/v1/sale-analysis/tax")
|
config.add_route("v1_sa_tax", "/v1/sale-analysis/tax")
|
||||||
config.add_route("v1_sale_analysis", "/v1/sale-analysis")
|
config.add_route("v1_sale_analysis", "/v1/sale-analysis")
|
||||||
|
config.add_route("sale_analysis", "/sale-analysis")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="sale_analysis",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Sales Analysis",
|
||||||
|
)
|
||||||
|
config.add_route("tax_analysis", "/tax-analysis")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="tax_analysis",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Tax Analysis",
|
||||||
|
)
|
||||||
|
|
||||||
config.add_route("v1_product_sale_report", "/v1/product-sale-report")
|
config.add_route("v1_product_sale_report", "/v1/product-sale-report")
|
||||||
|
config.add_route("product_sale_report", "/product-sale-report")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="product_sale_report",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Sales Detail",
|
||||||
|
)
|
||||||
config.add_route("v1_bill_settlement_report", "/v1/bill-settlement-report")
|
config.add_route("v1_bill_settlement_report", "/v1/bill-settlement-report")
|
||||||
|
config.add_route("bill_settlement_report", "/bill-settlement-report")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="bill_settlement_report",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Bill Details",
|
||||||
|
)
|
||||||
|
|
||||||
config.add_route("v1_beer_consumption_report", "/v1/beer-consumption-report")
|
config.add_route("v1_beer_consumption_report", "/v1/beer-consumption-report")
|
||||||
|
config.add_route("beer_consumption_report", "/beer-consumption-report")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="beer_consumption_report",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Beer Consumption",
|
||||||
|
)
|
||||||
|
|
||||||
config.add_route("v1_discount_report", "/v1/discount-report")
|
config.add_route("v1_discount_report", "/v1/discount-report")
|
||||||
|
config.add_route("discount_report", "/discount-report")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="discount_report",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Discount Report",
|
||||||
|
)
|
||||||
|
|
||||||
config.add_route("v1_voids_reprints_report", "/v1/voids-reprints-report")
|
config.add_route("v1_voids_reprints_report", "/v1/voids-reprints-report")
|
||||||
# Done till here
|
config.add_route("voids_reprints_report", "/voids-reprints-report")
|
||||||
|
config.add_view(
|
||||||
|
"barker.views.home",
|
||||||
|
route_name="voids_reprints_report",
|
||||||
|
request_method="GET",
|
||||||
|
permission="Void or Reprinted Bill Report",
|
||||||
|
)
|
||||||
|
# config.add_route("v1_bills_new", "/v1/bills/new")
|
||||||
|
# config.add_route("v1_bills_id", "/v1/bills/{id}")
|
||||||
|
|
||||||
config.add_route("customer", "/Customer.json")
|
config.add_route("v1_customers_new", "/v1/customers/new")
|
||||||
config.add_route("customer_list", "/Customers.json")
|
config.add_route("v1_customers_id", "/v1/customers/{id}")
|
||||||
config.add_route("customer_id", "/Customer/{id}.json")
|
config.add_route("v1_customers_list", "/v1/customers")
|
||||||
|
config.add_route("customers_new", "/customers/new")
|
||||||
|
config.add_view(
|
||||||
config.add_route("location_list", "/Locations.json")
|
"barker.views.home",
|
||||||
|
route_name="customers_new",
|
||||||
config.add_route("machine_location", "/MachineLocation.json")
|
request_method="GET",
|
||||||
config.add_route("machine_location_list", "/MachineLocations.json")
|
permission="Customers",
|
||||||
config.add_route("machine_location_id", "/MachineLocation/{id}.json")
|
)
|
||||||
|
config.add_route("customers_id", "/customers/{id}")
|
||||||
config.add_route("merge_kot", "/MergeKot.json")
|
config.add_view(
|
||||||
config.add_route("move_kot", "/MoveKot.json")
|
"barker.views.home",
|
||||||
|
route_name="customers_id",
|
||||||
config.add_route("permission_list", "/Permissions.json")
|
request_method="GET",
|
||||||
|
permission="Customers",
|
||||||
config.add_route("v1_bills_new", "/v1/bills/new")
|
)
|
||||||
config.add_route("v1_bills_id", "/v1/bills/{id}")
|
config.add_route("customers_list", "/customers")
|
||||||
|
config.add_view(
|
||||||
config.add_route("reprint", "/Reprint.json")
|
"barker.views.home",
|
||||||
config.add_route("reprint_report", "/ReprintReport.json")
|
route_name="customers_list",
|
||||||
|
request_method="GET",
|
||||||
config.add_route("setting", "/Setting.json")
|
permission="Authenticated",
|
||||||
config.add_route("setting_list", "/Settings.json")
|
)
|
||||||
config.add_route("setting_id", "/Setting/{id}.json")
|
|
||||||
|
|
||||||
config.add_route("voucher_reprint", "/ReprintVoucher/{id}.json")
|
|
||||||
|
|
||||||
config.add_route("api_lock_info", "/api/LockInfo")
|
|
||||||
config.add_route("api_maintenance", "/api/Maintenance")
|
|
||||||
|
|
||||||
# config.add_route('customer_id', '/Customer/{id}.json')
|
|
||||||
|
|
||||||
|
config.add_route("v1_reprint", "/v1/reprint/{id}")
|
||||||
|
config.add_route("v1_settings_id", "/v1/settings/{id}")
|
||||||
|
|
||||||
config.add_static_view("", "barker:static")
|
config.add_static_view("", "barker:static")
|
||||||
|
@ -6,7 +6,7 @@ from pyramid.view import view_config
|
|||||||
from barker.models import Customer
|
from barker.models import Customer
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='PUT', route_name='customer', renderer='json', permission='Customers', trans=True)
|
@view_config(request_method='PUT', route_name='v1_customers_new', renderer='json', permission='Customers', trans=True)
|
||||||
def save(request):
|
def save(request):
|
||||||
json = request.json_body
|
json = request.json_body
|
||||||
item = Customer(json['company'], json['name'], json['phone'], json['address'], json['important'])
|
item = Customer(json['company'], json['name'], json['phone'], json['address'], json['important'])
|
||||||
@ -16,7 +16,7 @@ def save(request):
|
|||||||
return customer_info(item)
|
return customer_info(item)
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='POST', route_name='customer_id', renderer='json', permission='Customers', trans=True)
|
@view_config(request_method='POST', route_name='v1_customers_id', renderer='json', permission='Customers', trans=True)
|
||||||
def update(request):
|
def update(request):
|
||||||
json = request.json_body
|
json = request.json_body
|
||||||
item = request.dbsession.query(Customer).filter(Customer.id == uuid.UUID(request.matchdict['id'])).first()
|
item = request.dbsession.query(Customer).filter(Customer.id == uuid.UUID(request.matchdict['id'])).first()
|
||||||
@ -30,7 +30,7 @@ def update(request):
|
|||||||
return customer_info(item)
|
return customer_info(item)
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='DELETE', route_name='customer_id', renderer='json', permission='Customers', trans=True)
|
@view_config(request_method='DELETE', route_name='v1_customers_id', renderer='json', permission='Customers', trans=True)
|
||||||
def delete(request):
|
def delete(request):
|
||||||
item = request.dbsession.query(Customer).filter(Customer.id == uuid.UUID(request.matchdict['id'])).first()
|
item = request.dbsession.query(Customer).filter(Customer.id == uuid.UUID(request.matchdict['id'])).first()
|
||||||
request.dbsession.delete(item)
|
request.dbsession.delete(item)
|
||||||
@ -38,18 +38,18 @@ def delete(request):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='GET', route_name='customer_id', renderer='json', permission='Authenticated')
|
@view_config(request_method='GET', route_name='v1_customers_id', renderer='json', permission='Authenticated')
|
||||||
def show_id(request):
|
def show_id(request):
|
||||||
id = uuid.UUID(request.matchdict['id'])
|
id_ = uuid.UUID(request.matchdict['id'])
|
||||||
item = request.dbsession.query(Customer).filter(Customer.id == id).first()
|
item = request.dbsession.query(Customer).filter(Customer.id == id_).first()
|
||||||
return customer_info(item)
|
return customer_info(item)
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='GET', route_name='customer_list', renderer='json', permission='Authenticated')
|
@view_config(request_method='GET', route_name='v1_customers_list', renderer='json', permission='Authenticated')
|
||||||
def show_list(request):
|
def show_list(request):
|
||||||
list = request.dbsession.query(Customer).order_by(Customer.name).all()
|
list_ = request.dbsession.query(Customer).order_by(Customer.name).all()
|
||||||
customers = []
|
customers = []
|
||||||
for item in list:
|
for item in list_:
|
||||||
customers.append({
|
customers.append({
|
||||||
'id': item.id,
|
'id': item.id,
|
||||||
'company': item.company,
|
'company': item.company,
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
import transaction
|
import transaction
|
||||||
from pyramid.view import view_config
|
from pyramid.view import view_config
|
||||||
|
|
||||||
from barker.models import Reprint
|
from barker.models import Reprint
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='PUT', route_name='reprint', renderer='json', permission='Print Bill', trans=True)
|
@view_config(request_method='POST', route_name='v1_reprint', renderer='json', permission='Print Bill', trans=True)
|
||||||
def save(request):
|
def save(request):
|
||||||
json = request.json_body
|
id_ = uuid.UUID(request.matchdict['id'])
|
||||||
item = Reprint(json['User']['UserID'], json['Voucher']['VoucherID'])
|
item = Reprint(id_, uuid.UUID(request.authenticated_userid))
|
||||||
request.dbsession.add(item)
|
request.dbsession.add(item)
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
item = request.dbsession.query(Reprint).filter(Reprint.id == item.id).first()
|
return True
|
||||||
return reprint_info(item)
|
|
||||||
|
|
||||||
|
|
||||||
def reprint_info(item):
|
|
||||||
return {
|
|
||||||
'ReprintID': item.id,
|
|
||||||
'User': {'UserID': item.user_id, 'Name': item.user.name},
|
|
||||||
'Voucher': {'VoucherID': item.voucher_id, 'BillID': item.bill_id},
|
|
||||||
}
|
|
||||||
|
@ -3,7 +3,7 @@ from pyramid.view import view_config
|
|||||||
from barker.models import DbSetting
|
from barker.models import DbSetting
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='GET', route_name='setting_id', renderer='json', permission='Authenticated')
|
@view_config(request_method='GET', route_name='v1_settings_id', renderer='json', permission='Authenticated')
|
||||||
def show_id(request):
|
def show_id(request):
|
||||||
name = request.matchdict['id']
|
name = request.matchdict['id']
|
||||||
item = request.dbsession.query(DbSetting).filter(DbSetting.name == name).first()
|
item = request.dbsession.query(DbSetting).filter(DbSetting.name == name).first()
|
||||||
|
@ -1,42 +1,42 @@
|
|||||||
import uuid
|
# import uuid
|
||||||
|
#
|
||||||
import transaction
|
# import transaction
|
||||||
from pyramid.view import view_config
|
# from pyramid.view import view_config
|
||||||
|
#
|
||||||
from barker.models import Voucher, Overview
|
# from barker.models import Voucher, Overview
|
||||||
from barker.views.voucher.save import save
|
# from barker.views.voucher.save import save
|
||||||
from barker.views.voucher.show import voucher_info
|
# from barker.views.voucher.show import voucher_info
|
||||||
|
#
|
||||||
|
#
|
||||||
@view_config(
|
# @view_config(
|
||||||
request_method="POST",
|
# request_method="POST",
|
||||||
route_name="voucher_reprint",
|
# route_name="voucher_reprint",
|
||||||
renderer="json",
|
# renderer="json",
|
||||||
permission="Edit Printed Bill",
|
# permission="Edit Printed Bill",
|
||||||
trans=True,
|
# trans=True,
|
||||||
) # Permission error
|
# ) # Permission error
|
||||||
def voucher_change(request):
|
# def voucher_change(request):
|
||||||
json = request.json_body
|
# json = request.json_body
|
||||||
id_ = uuid.UUID(request.matchdict["id"])
|
# id_ = uuid.UUID(request.matchdict["id"])
|
||||||
item = save(json, request.dbsession)
|
# item = save(json, request.dbsession)
|
||||||
old = request.dbsession.query(Voucher).filter(Voucher.id == id_).first()
|
# old = request.dbsession.query(Voucher).filter(Voucher.id == id_).first()
|
||||||
old.void = True
|
# old.void = True
|
||||||
old.void_reason = "Bill Discounted / Changed. New Bill ID is {0}".format(
|
# old.void_reason = "Bill Discounted / Changed. New Bill ID is {0}".format(
|
||||||
item.full_bill_id
|
# item.full_bill_id
|
||||||
)
|
# )
|
||||||
# TODO: Set the Void Settlement
|
# # TODO: Set the Void Settlement
|
||||||
|
#
|
||||||
if old.status is None:
|
# if old.status is None:
|
||||||
item.status = Overview(
|
# item.status = Overview(
|
||||||
voucher_id=None, food_table_id=item.food_table_id, status="printed"
|
# voucher_id=None, food_table_id=item.food_table_id, status="printed"
|
||||||
)
|
# )
|
||||||
request.dbsession.add(item.status)
|
# request.dbsession.add(item.status)
|
||||||
else:
|
# else:
|
||||||
request.dbsession.query(Overview).filter(Overview.voucher_id == old.id).update(
|
# request.dbsession.query(Overview).filter(Overview.voucher_id == old.id).update(
|
||||||
{Overview.voucher_id: item.id}
|
# {Overview.voucher_id: item.id}
|
||||||
)
|
# )
|
||||||
transaction.commit()
|
# transaction.commit()
|
||||||
item = request.dbsession.query(Voucher).filter(Voucher.id == item.id).first()
|
# item = request.dbsession.query(Voucher).filter(Voucher.id == item.id).first()
|
||||||
return voucher_info(item)
|
# return voucher_info(item)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user