Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2pext
plugin_dbui
Commits
c64a45b9
Commit
c64a45b9
authored
9 years ago
by
LE GAC Renaud
Browse files
Options
Downloads
Patches
Plain Diff
Run pylint checker on plugin_dbui/converter.py
parent
bd40af67
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!15
Release 0.7.3
,
!10
14 pylint jslint
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/plugin_dbui/converter.py
+54
-28
54 additions, 28 deletions
modules/plugin_dbui/converter.py
with
54 additions
and
28 deletions
modules/plugin_dbui/converter.py
+
54
−
28
View file @
c64a45b9
...
...
@@ -4,8 +4,32 @@
import
gluon.dal
import
re
from
extjs
import
*
from
extjs
import
(
Base
,
CheckBox
,
ComboBox
,
DirectStore
,
FieldContainer
,
FieldDate
,
FieldDict
,
FieldList
,
FieldNumber
,
FieldSet
,
FieldText
,
FieldTextArea
,
FieldTime
,
FormPanel
,
GridColumn
,
GridColumnModel
,
GridFilter
,
GridPanel
,
GridRowNumberer
,
GridTemplateColumn
,
GridWithFilter
,
Model
,
PanelWithUrlSelector
)
from
gluon
import
current
from
gluon.tools
import
PluginManager
from
gridmodifier
import
ROW_NUMBERING
from
helper
import
(
encode_field
,
get_field_validators
,
...
...
@@ -18,21 +42,21 @@ from mapper import map_default
# Associated gluon.dal.field type with an ExtJS widget
# The dictionary contains configuration parameters of the Ext JS widget
FTYPE_TO_XTYPE
=
{
'
boolean
'
:
(
CheckBox
,
{}),
\
'
date
'
:
(
FieldDate
,
{
'
format
'
:
'
Y-m-d
'
}),
\
'
datetime
'
:
(
FieldDate
,
{
'
format
'
:
'
Y-m-d H:i:s
'
}),
\
'
double
'
:
(
FieldNumber
,
{
'
decimalPrecision
'
:
2
,
'
decimalSeparator
'
:
'
.
'
}),
\
'
id
'
:
(
FieldText
,
{}),
\
'
integer
'
:
(
FieldNumber
,
{}),
\
FTYPE_TO_XTYPE
=
{
'
boolean
'
:
(
CheckBox
,
{}),
'
date
'
:
(
FieldDate
,
{
'
format
'
:
'
Y-m-d
'
}),
'
datetime
'
:
(
FieldDate
,
{
'
format
'
:
'
Y-m-d H:i:s
'
}),
'
double
'
:
(
FieldNumber
,
{
'
decimalPrecision
'
:
2
,
'
decimalSeparator
'
:
'
.
'
}),
'
id
'
:
(
FieldText
,
{}),
'
integer
'
:
(
FieldNumber
,
{}),
'
json
'
:
(
FieldDict
,
{}),
'
list:string
'
:
(
FieldList
,
{}),
\
'
list:integer
'
:
(
FieldTextArea
,
{}),
\
'
password
'
:
(
FieldText
,
{
'
inputType
'
:
'
password
'
}),
\
'
reference
'
:
(
ComboBox
,
{}),
\
'
string
'
:
(
FieldText
,
{}),
\
'
text
'
:
(
FieldTextArea
,
{}),
\
'
time
'
:
(
FieldTime
,
{}),
\
'
list:string
'
:
(
FieldList
,
{}),
'
list:integer
'
:
(
FieldTextArea
,
{}),
'
password
'
:
(
FieldText
,
{
'
inputType
'
:
'
password
'
}),
'
reference
'
:
(
ComboBox
,
{}),
'
string
'
:
(
FieldText
,
{}),
'
text
'
:
(
FieldTextArea
,
{}),
'
time
'
:
(
FieldTime
,
{}),
'
upload
'
:
(
FieldText
,
{
'
inputType
'
:
'
file
'
})}
...
...
@@ -240,7 +264,8 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs):
cfg
.
update
(
composite_fields
[
field
.
name
].
extjs
)
# an embedded field already used in a composite field
elif
composite
and
composite_fields
and
field
.
name
in
composite_fields
.
others
:
elif
composite
\
and
composite_fields
and
field
.
name
in
composite_fields
.
others
:
cfg
=
None
# a basic field
...
...
@@ -641,11 +666,11 @@ def to_gridPanel(table, **kwargs):
# configuration option from the keyword arguments
cfg
.
update
(
kwargs
)
# grid with filter
filter
=
to_gridFilter
(
table
)
if
filter
:
# grid with
grid_
filter
grid_
filter
=
to_gridFilter
(
table
)
if
grid_
filter
:
cfg
=
GridWithFilter
(
panelItems
=
dict
(
cfg
),
selectorItems
=
filter
)
selectorItems
=
grid_
filter
)
if
tablename
in
modifier_grids
:
cfg
.
update
(
modifier_grids
[
tablename
].
grid_with_filter
.
extjs
)
...
...
@@ -672,7 +697,6 @@ def to_jsonstore(table, **kwargs):
DirectStore
"""
db
=
table
.
_db
tablename
=
table
.
_tablename
# NOTE: the configuration option extraParams defined the
...
...
@@ -710,7 +734,8 @@ def to_jsonstore(table, **kwargs):
# in form and in grid.
if
is_foreign_field
(
field
):
if
'
where
'
not
in
base_params
:
base_params
[
'
where
'
]
=
[]
if
'
where
'
not
in
base_params
:
base_params
[
'
where
'
]
=
[]
# the foreign field
k_tablename
,
k_fieldname
,
k_key
=
get_foreign_field
(
field
)
...
...
@@ -729,17 +754,17 @@ def to_jsonstore(table, **kwargs):
for
el
in
modifier_stores
[
tablename
].
orderby
:
if
isinstance
(
el
,
gluon
.
dal
.
Field
):
field
,
dir
=
el
,
'
ASC
'
field
,
dir
ection
=
el
,
'
ASC
'
elif
isinstance
(
el
,
gluon
.
dal
.
Expression
):
field
,
dir
=
el
.
first
,
'
DESC
'
field
,
dir
ection
=
el
.
first
,
'
DESC
'
base_params
[
'
orderby
'
].
append
([
field
.
tablename
,
field
.
name
,
dir
])
li
=
[
field
.
tablename
,
field
.
name
,
direction
]
base_params
[
'
orderby
'
].
append
(
li
)
# Ext JS configuration option from the modifier
cfg
.
update
(
modifier_stores
[
tablename
].
extjs
)
# Ext JS configuration options from the keyword arguments
cfg
.
update
(
kwargs
)
...
...
@@ -773,7 +798,8 @@ def to_model(table):
# the default value can be a callable.
# that case makes no sense on the client side
# in addition the JSON dumps will failed
# therefore the default value are limited to types which can be JSONify.
# therefore the default value are limited to types which
# can be JSONifyied.
default
=
field
.
default
if
default
and
isinstance
(
default
,
JSON_TYPES
):
field_cfg
[
'
defaultValue
'
]
=
default
...
...
@@ -896,4 +922,4 @@ def to_viewport(**kwargs):
# configuration options from the keyword arguments
cfg
.
update
(
kwargs
)
return
cfg
\ No newline at end of file
return
cfg
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment