Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 16b427a9
authored
Dec 04, 2024
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
config
1 parent
50ea681f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
16 deletions
opensipkd/base/__init__.py
opensipkd/base/tools/report.py
opensipkd/base/views/base_views.py
opensipkd/base/views/routes.py
opensipkd/base/views/widget_os.py
opensipkd/base/views/widgets/textinput_btn.pt
opensipkd/base/__init__.py
View file @
16b427a
import
importlib
import
locale
import
locale
import
logging
import
logging
import
re
import
re
...
@@ -464,6 +465,41 @@ def _set_routes2(config, module="base"):
...
@@ -464,6 +465,41 @@ def _set_routes2(config, module="base"):
return
q
return
q
def
add_view_config
(
config
,
module
,
view_name
):
"""
Digunakan untuk mengenerate view_config berdasarkan tabel Routes
config: config
module: application module
views: class or file tobe imported
"""
q
=
DBSession
.
query
(
Route
)
.
filter
(
Route
.
module
==
module
,
Route
.
status
==
1
)
for
row
in
q
.
all
():
if
row
.
type
==
0
:
config
.
add_route
(
row
.
kode
,
row
.
path
)
if
row
.
nama
:
titles
[
row
.
kode
]
=
row
.
nama
elif
row
.
type
==
1
:
config
.
add_jsonrpc_endpoint
(
row
.
kode
,
row
.
path
,
default_renderer
=
"json_rpc"
)
if
not
row
.
def_func
:
continue
class_view
=
row
.
class_view
and
f
".{row.class_view}"
or
""
class_name
=
f
"{view_name}{class_view}"
attr
=
f
"view_{row.def_func}"
log
.
debug
(
f
"Class: {class_name} Attr: {attr}"
)
_views
=
importlib
.
import_module
(
class_name
)
views
=
_views
if
row
.
template
==
"json"
:
renderer
=
row
.
template
else
:
renderer
=
"views/templates/"
+
row
.
template
config
.
add_view
(
views
.
Views
,
attr
=
f
"{attr}"
,
route_name
=
row
.
kode
,
permission
=
row
.
permission
,
renderer
=
renderer
)
config
.
scan
(
'.'
)
def
set_routes
(
config
,
app_id
=
None
):
def
set_routes
(
config
,
app_id
=
None
):
if
app_id
and
type
(
app_id
)
==
str
:
if
app_id
and
type
(
app_id
)
==
str
:
return
_set_routes2
(
config
,
app_id
)
return
_set_routes2
(
config
,
app_id
)
...
...
opensipkd/base/tools/report.py
View file @
16b427a
...
@@ -108,10 +108,6 @@ def jasper_export(input_file, output_file=None, schema=None,
...
@@ -108,10 +108,6 @@ def jasper_export(input_file, output_file=None, schema=None,
}
}
pyreportjasper
=
PyReportJasper
()
pyreportjasper
=
PyReportJasper
()
# log.info(input_file)
# log.info(output_file)
# log.info(conn)
# log.info(output_formats)
parameters
.
update
({
'python_version'
:
python_version
()})
parameters
.
update
({
'python_version'
:
python_version
()})
pyreportjasper
.
config
(
pyreportjasper
.
config
(
input_file
,
input_file
,
...
@@ -122,8 +118,17 @@ def jasper_export(input_file, output_file=None, schema=None,
...
@@ -122,8 +118,17 @@ def jasper_export(input_file, output_file=None, schema=None,
locale
=
report_locale
locale
=
report_locale
)
)
# pyreportjasper.compile(write_jasper=True)
try
:
pyreportjasper
.
process_report
()
log
.
info
(
input_file
)
# log.info(output_file)
# log.info(conn)
# log.info(output_formats)
pyreportjasper
.
compile
(
write_jasper
=
True
)
pyreportjasper
.
process_report
()
except
Exception
as
e
:
log
.
debug
(
e
)
raise
output_files
=
[
"."
.
join
([
output_file
,
f
])
for
f
in
output_formats
]
output_files
=
[
"."
.
join
([
output_file
,
f
])
for
f
in
output_formats
]
log
.
info
(
output_files
)
log
.
info
(
output_files
)
return
output_files
return
output_files
\ No newline at end of file
\ No newline at end of file
opensipkd/base/views/base_views.py
View file @
16b427a
...
@@ -137,7 +137,7 @@ class BaseView(object):
...
@@ -137,7 +137,7 @@ class BaseView(object):
self
.
form_params
=
dict
(
scripts
=
""
)
self
.
form_params
=
dict
(
scripts
=
""
)
self
.
list_url
=
''
self
.
list_url
=
''
self
.
list_route
=
''
self
.
list_route
=
''
self
.
list_schema
=
""
self
.
list_schema
=
colander
.
Schema
self
.
form_scripts
=
"""
self
.
form_scripts
=
"""
$('#parent_nm').bind('typeahead:selected', function(obj, datum) {
$('#parent_nm').bind('typeahead:selected', function(obj, datum) {
$('#parent_id').val(datum.id);
$('#parent_id').val(datum.id);
...
@@ -146,8 +146,8 @@ class BaseView(object):
...
@@ -146,8 +146,8 @@ class BaseView(object):
});"""
});"""
self
.
form_widget
=
None
self
.
form_widget
=
None
self
.
edit_schema
=
""
self
.
edit_schema
=
colander
.
Schema
()
self
.
add_schema
=
""
self
.
add_schema
=
colander
.
Schema
()
self
.
upload_schema
=
UploadSchema
self
.
upload_schema
=
UploadSchema
self
.
upload_exts
=
(
".csv"
,
".tsv"
)
self
.
upload_exts
=
(
".csv"
,
".tsv"
)
self
.
upload_keys
=
[
"kode"
]
self
.
upload_keys
=
[
"kode"
]
...
...
opensipkd/base/views/routes.py
View file @
16b427a
...
@@ -2,10 +2,11 @@ import logging
...
@@ -2,10 +2,11 @@ import logging
import
colander
import
colander
from
deform
import
(
widget
,
)
from
deform
import
(
widget
,
)
from
opensipkd.models
import
(
DBSession
,
Route
,
)
from
opensipkd.tools.buttons
import
btn_view
,
btn_edit
,
btn_delete
from
pyramid.view
import
view_config
from
pyramid.view
import
view_config
from
sqlalchemy.orm
import
aliased
from
sqlalchemy.orm
import
aliased
from
opensipkd.models
import
(
DBSession
,
Route
,
)
from
opensipkd.tools.buttons
import
btn_view
,
btn_edit
,
btn_delete
from
.
import
BaseView
,
get_urls
from
.
import
BaseView
,
get_urls
_logging
=
logging
.
getLogger
(
__name__
)
_logging
=
logging
.
getLogger
(
__name__
)
...
@@ -93,7 +94,10 @@ class EditSchema(colander.Schema):
...
@@ -93,7 +94,10 @@ class EditSchema(colander.Schema):
colander
.
String
(),
colander
.
String
(),
widget
=
widget
.
CheckboxWidget
(
false_val
=
"0"
,
true_val
=
"1"
))
widget
=
widget
.
CheckboxWidget
(
false_val
=
"0"
,
true_val
=
"1"
))
alias
=
aliased
(
Route
)
alias
=
aliased
(
Route
)
class
ListSchema
(
colander
.
Schema
):
class
ListSchema
(
colander
.
Schema
):
id
=
colander
.
SchemaNode
(
id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
widget
=
widget
.
HiddenWidget
(),
visible
=
False
)
colander
.
Integer
(),
widget
=
widget
.
HiddenWidget
(),
visible
=
False
)
...
@@ -102,11 +106,22 @@ class ListSchema(colander.Schema):
...
@@ -102,11 +106,22 @@ class ListSchema(colander.Schema):
parent
=
colander
.
SchemaNode
(
parent
=
colander
.
SchemaNode
(
colander
.
String
(),
colander
.
String
(),
field
=
alias
.
kode
)
field
=
alias
.
kode
)
order_id
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
"Order"
)
is_menu
=
colander
.
SchemaNode
(
colander
.
Boolean
(),
widget
=
widget
.
CheckboxWidget
(
false_val
=
"0"
,
true_val
=
"1"
),
title
=
"Menu"
)
nama
=
colander
.
SchemaNode
(
nama
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
'Nama'
)
colander
.
String
(),
title
=
'Nama'
)
path
=
colander
.
SchemaNode
(
path
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
'Path'
)
colander
.
String
(),
title
=
'Path'
)
template
=
colander
.
SchemaNode
(
colander
.
String
())
type
=
colander
.
SchemaNode
(
type
=
colander
.
SchemaNode
(
colander
.
String
(),
width
=
"50pt"
)
colander
.
String
(),
width
=
"50pt"
)
status
=
colander
.
SchemaNode
(
status
=
colander
.
SchemaNode
(
...
@@ -147,7 +162,8 @@ class Views(BaseView):
...
@@ -147,7 +162,8 @@ class Views(BaseView):
permission
=
'edit-title'
)
permission
=
'edit-title'
)
def
view_list
(
self
):
def
view_list
(
self
):
kwargs
=
{
"allow_view"
:
False
,
kwargs
=
{
"allow_view"
:
False
,
"allow_delete"
:
False
}
"allow_delete"
:
False
,
"state_save"
:
True
}
return
super
()
.
view_list
(
**
kwargs
)
return
super
()
.
view_list
(
**
kwargs
)
def
form_validator
(
self
,
form
,
values
):
def
form_validator
(
self
,
form
,
values
):
...
...
opensipkd/base/views/widget_os.py
View file @
16b427a
...
@@ -710,13 +710,15 @@ class BootStrapDateTimeInputWidget(Widget):
...
@@ -710,13 +710,15 @@ class BootStrapDateTimeInputWidget(Widget):
class
TextInputWidget
(
widget
.
TextInputWidget
):
class
TextInputWidget
(
widget
.
TextInputWidget
):
template
=
"textinput_btn"
template
=
"textinput_btn"
button
=
None
button
=
None
js
=
None
def
__init__
(
self
,
**
kw
):
def
__init__
(
self
,
**
kw
):
super
(
TextInputWidget
,
self
)
.
__init__
(
**
kw
)
super
(
TextInputWidget
,
self
)
.
__init__
(
**
kw
)
# if isinstance(self.button, compat.string_types):
# if isinstance(self.button, compat.string_types):
if
isinstance
(
self
.
button
,
str
):
if
self
.
button
:
self
.
button
=
Button
(
self
.
button
,
type
=
"button"
)
if
isinstance
(
self
.
button
,
str
):
self
.
button
=
Button
(
self
.
button
,
type
=
"button"
)
class
DateInputWidget
(
WidgetDateInputWidget
):
class
DateInputWidget
(
WidgetDateInputWidget
):
...
@@ -754,4 +756,4 @@ class MoneyInputWidget(widget.MoneyInputWidget):
...
@@ -754,4 +756,4 @@ class MoneyInputWidget(widget.MoneyInputWidget):
# tmpl_values = self.get_template_values(field, cstruct, kw)
# tmpl_values = self.get_template_values(field, cstruct, kw)
# template = readonly and self.readonly_template or self.template
# template = readonly and self.readonly_template or self.template
# return field.renderer(template, **tmpl_values)
# return field.renderer(template, **tmpl_values)
#
#
\ No newline at end of file
\ No newline at end of file
opensipkd/base/views/widgets/textinput_btn.pt
View file @
16b427a
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
button button|field.widget.button;
button button|field.widget.button;
mask_placeholder mask_placeholder|field.widget.mask_placeholder;
mask_placeholder mask_placeholder|field.widget.mask_placeholder;
style style|field.widget.style;
style style|field.widget.style;
js js|field.widget.js;
" tal:omit-tag="">
" tal:omit-tag="">
<input type="text" tal:attributes="class string: form-control ${css_class or ''};
<input type="text" tal:attributes="class string: form-control ${css_class or ''};
style style;
style style;
...
@@ -30,6 +31,14 @@
...
@@ -30,6 +31,14 @@
${button.title}
${button.title}
</a>
</a>
</span>
</span>
<script tal:condition="js" type="text/javascript">
deform.addCallback(
'${oid+button.name}',
function (oid) {
${structure:js}
});
</script>
</div><!-- /input-group -->
</div><!-- /input-group -->
<script tal:condition="mask" type="text/javascript">
<script tal:condition="mask" type="text/javascript">
...
...
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