Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Kunto
/
backoffice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8f98178e
authored
Jul 30, 2019
by
Solo Group
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
http://git.opensipkd.com:8088/pasar/api-merchant
2 parents
d9000a78
9290f0ee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
168 additions
and
2 deletions
src/agratek/api/merchant/scripts/data/routes.csv
src/agratek/api/merchant/views/list_vendor.py
src/agratek/api/merchant/views/produlk.py
src/agratek/api/merchant/views/produlk_vemdor.py
src/agratek/api/merchant/scripts/data/routes.csv
View file @
8f98178
...
...
@@ -9,6 +9,7 @@ api-merchant-delete,/api/merchant/{id}/delete,Delete Api Merchant,1,0
api-merchant-view,/api/merchant/{id}/view,View Api Merchant,1,0
api-merchant-doc,/api/merchant/doc,Doc Api Merchant,1,0
api-vendor-act,/api/vendor/{act}/act,Act Vendor,1,0
api-vendor-list,/api/vendor/list,Test Api Vendor,1,0
api-vendor-add,/api/vendor/add,Add Api Vendor,1,0
api-vendor-edit,/api/vendor/{id}/edit,Edit Api Vendor,1,0
...
...
src/agratek/api/merchant/views/list_vendor.py
0 → 100644
View file @
8f98178
from
datetime
import
datetime
import
colander
from
datatables
import
ColumnDT
from
deform
import
widget
,
Form
,
ValidationFailure
from
opensipkd.base.views
import
DataTables
from
pyramid.httpexceptions
import
HTTPFound
from
pyramid.view
import
view_config
from
sqlalchemy
import
case
from
.
import
BaseView
# , save_file_upload
from
..models
import
(
DBSession
,
flush_row
,
PartnerLog
,
Produk
,
Partner
)
from
..tools
import
(
btn_cancel
,
btn_delete
)
def
form_validator
(
form
,
value
):
pass
def
get_form
(
request
,
class_form
,
buttons
=
None
,
row
=
None
):
schema
=
class_form
(
validator
=
form_validator
)
schema
.
request
=
request
if
row
:
schema
.
deserialize
(
row
)
return
Form
(
schema
,
buttons
=
buttons
)
def
route_list
(
request
):
return
HTTPFound
(
location
=
request
.
route_url
(
'api-vendor-list'
))
form_params_view
=
dict
(
scripts
=
"""
$(document).ready(function(){
});
"""
)
def
id_not_found
(
request
):
id
=
request
.
matchdict
[
'id'
]
request
.
session
.
flash
(
'Data
%
s Tidak Ditemukan'
%
id
,
'error'
)
return
route_list
(
request
)
def
query_id
(
request
):
id
=
request
.
matchdict
[
'id'
]
return
PartnerLog
.
query_id
(
id
)
class
ViewData
(
BaseView
):
@view_config
(
route_name
=
'api-vendor-list'
,
permission
=
"api-vendor-list"
,
renderer
=
'templates/list.pt'
)
def
view_list
(
self
):
params
=
{
'columns'
:
[
dict
(
title
=
"ID"
),
# dict(title="Customer"),
dict
(
title
=
"Vendor"
),
dict
(
title
=
"Nama Produk"
),
dict
(
title
=
"TRX Customer"
),
dict
(
title
=
"TRX Vendor"
),
dict
(
title
=
"ID Pelanggan"
),
dict
(
title
=
"Nilai Beli"
),
dict
(
title
=
"Nilai Jual"
),
dict
(
title
=
"Amount Oth 1"
),
dict
(
title
=
"Amount Oth 2"
),
dict
(
title
=
"Amount Oth 3"
),
dict
(
title
=
"Amount Oth 4"
),
dict
(
title
=
"Amount Oth 5"
),
],
'column_data'
:
[
dict
(
data
=
"id"
,
width
=
"0px"
),
# dict(data="customer"),
dict
(
data
=
"vendor"
),
dict
(
data
=
"produk_nama"
),
dict
(
data
=
"cust_trx"
),
dict
(
data
=
"vend_trx"
),
dict
(
data
=
"bill_no"
),
dict
(
data
=
"amt_buy"
),
dict
(
data
=
"amt_sell"
),
dict
(
data
=
"amt_oth1"
),
dict
(
data
=
"amt_oth2"
),
dict
(
data
=
"amt_oth3"
),
dict
(
data
=
"amt_oth4"
),
dict
(
data
=
"amt_oth5"
),
],
'buttons'
:
[
dict
(
id
=
"btn_delete"
,
cls
=
"btn btn btn-primary"
,
title
=
"Hapus"
),
dict
(
id
=
"btn_close"
,
cls
=
"btn btn-danger"
,
title
=
"Tutup"
),
],
'route'
:
"/api/vendor"
,
'scripts'
:
"""
$('#btn_delete').click(function() {
if (mID) window.location = oTableUri + '/' + mID + '/delete';
else
$.SmartMessageBox({
title : "Delete",
content : "Pilih Baris yang akan di hapus...",
buttons : '[Oke]'
});;
});
$("#btn_close").click(function() {
window.location = '/api/merchant';
return false;
});
"""
}
return
dict
(
params
=
params
)
@view_config
(
route_name
=
'api-vendor-act'
,
renderer
=
'json'
,
permission
=
"api-vendor-list"
)
def
view_act
(
self
):
request
=
self
.
req
url_dict
=
request
.
matchdict
act
=
url_dict
[
'act'
]
if
act
==
"grid"
:
columns
=
[
ColumnDT
(
PartnerLog
.
id
,
mData
=
'id'
),
ColumnDT
(
case
(
whens
=
(
(
Partner
.
is_customer
!=
0
,
Partner
.
nama
),
(
Partner
.
is_customer
==
0
,
'-'
),
)
)
,
mData
=
"customer"
),
# ColumnDT(Partner.nama, mData='customer'),
ColumnDT
(
Partner
.
nama
,
mData
=
'vendor'
),
ColumnDT
(
Produk
.
nama
,
mData
=
'produk_nama'
),
ColumnDT
(
PartnerLog
.
cust_trx
,
mData
=
'cust_trx'
),
ColumnDT
(
PartnerLog
.
vend_trx
,
mData
=
'vend_trx'
),
ColumnDT
(
PartnerLog
.
bill_no
,
mData
=
'bill_no'
),
ColumnDT
(
PartnerLog
.
amt_buy
,
mData
=
'amt_buy'
),
ColumnDT
(
PartnerLog
.
amt_sell
,
mData
=
'amt_sell'
),
ColumnDT
(
PartnerLog
.
amt_oth1
,
mData
=
'amt_oth1'
),
ColumnDT
(
PartnerLog
.
amt_oth2
,
mData
=
'amt_oth2'
),
ColumnDT
(
PartnerLog
.
amt_oth3
,
mData
=
'amt_oth3'
),
ColumnDT
(
PartnerLog
.
amt_oth4
,
mData
=
'amt_oth4'
),
ColumnDT
(
PartnerLog
.
amt_oth5
,
mData
=
'amt_oth5'
),
]
query
=
DBSession
.
query
()
.
select_from
(
PartnerLog
)
.
join
(
Produk
,
Produk
.
id
==
PartnerLog
.
produk_id
)
.
join
(
Partner
,
Partner
.
id
==
PartnerLog
.
vendor_id
)
.
\
filter
(
Partner
.
id
==
PartnerLog
.
vendor_id
)
row_table
=
DataTables
(
request
.
GET
,
query
,
columns
)
return
row_table
.
output_result
()
@view_config
(
route_name
=
'api-vendor-delete'
,
renderer
=
'templates/form.pt'
,
permission
=
"api-vendor-admin"
)
def
view_delete
(
self
):
request
=
self
.
req
# form = get_form(request, EditSchema, (btn_cancel, btn_delete))
form
=
Form
(
colander
.
Schema
(),
buttons
=
(
btn_cancel
,
btn_delete
))
for
f
in
form
:
form
[
f
]
.
widget
.
readonly
=
True
query
=
query_id
(
request
)
row
=
query
.
first
()
if
not
row
:
return
id_not_found
(
request
)
if
request
.
POST
:
if
'delete'
in
request
.
POST
:
request
.
session
.
flash
(
'Data
%
d berhasil dihapus'
%
row
.
id
)
query
.
delete
()
return
route_list
(
request
)
values
=
row
.
to_dict
()
form
.
render
(
values
)
return
dict
(
form
=
form
,
params
=
{
"scripts"
:
None
})
src/agratek/api/merchant/views/produlk.py
View file @
8f98178
...
...
@@ -256,7 +256,8 @@ class ViewData(BaseView):
permission
=
"api-produk-admin"
)
def
view_delete
(
self
):
request
=
self
.
req
form
=
get_form
(
request
,
EditSchema
,
(
btn_cancel
,
btn_delete
))
# form = get_form(request, EditSchema, (btn_cancel, btn_delete))
form
=
Form
(
colander
.
Schema
(),
EditSchema
,
buttons
=
(
btn_cancel
,
btn_delete
))
for
f
in
form
:
form
[
f
]
.
widget
.
readonly
=
True
query
=
query_id
(
request
)
...
...
src/agratek/api/merchant/views/produlk_vemdor.py
View file @
8f98178
...
...
@@ -257,7 +257,8 @@ class ViewData(BaseView):
permission
=
"api-produk-vendor-admin"
)
def
view_delete
(
self
):
request
=
self
.
req
form
=
get_form
(
request
,
EditSchema
,
(
btn_cancel
,
btn_delete
))
# form = get_form(request, EditSchema, (btn_cancel, btn_delete))
form
=
Form
(
colander
.
Schema
(),
EditSchema
,
buttons
=
(
btn_cancel
,
btn_delete
))
for
f
in
form
:
form
[
f
]
.
widget
.
readonly
=
True
query
=
query_id
(
request
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment