Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
fa3ebedf
Commit
fa3ebedf
authored
Jan 21, 2016
by
LE GAC Renaud
Browse files
Apply pylint rules on callback.py and my_validators.py.
parent
b1d537f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
modules/callbacks.py
modules/callbacks.py
+12
-9
modules/my_validators.py
modules/my_validators.py
+0
-2
No files found.
modules/callbacks.py
View file @
fa3ebedf
...
...
@@ -7,23 +7,27 @@ from gluon import current
from
plugin_dbui
import
CALLBACK_ERRORS
,
get_where_query
def
INHIBIT_CASCADE_DELETE
(
set
):
MSG_INHIBIT_DELETE
=
\
"Can't delete this record since several transactions refer to it."
def
INHIBIT_CASCADE_DELETE
(
myset
):
"""Inhibit the delete when at least one history row uses
the reference field.
@type set: gluon.dal.Set
@param set:
@type
my
set: gluon.dal.Set
@param
my
set:
@rtype: bool
@return:
"""
db
,
T
=
current
.
globalenv
[
'db'
],
current
.
T
field
=
set
.
query
.
first
field
=
my
set
.
query
.
first
# protection
# the query of the set should be "table.id == 45"
if
field
.
_db
.
_adapter
.
EQ
!=
set
.
query
.
op
:
if
field
.
_db
.
_adapter
.
EQ
!=
my
set
.
query
.
op
:
return
False
# protection
...
...
@@ -40,11 +44,10 @@ def INHIBIT_CASCADE_DELETE(set):
# inhibit the delete if at least one history row use the reference field
query
=
get_where_query
(
db
.
history
)
query
=
(
query
)
&
(
set
.
query
)
query
=
(
query
)
&
(
my
set
.
query
)
if
db
(
query
).
count
():
field
.
_table
[
CALLBACK_ERRORS
]
=
\
T
(
"Can't delete this record since several transactions refer to it."
)
field
.
_table
[
CALLBACK_ERRORS
]
=
T
(
MSG_INHIBIT_DELETE
)
return
True
return
False
\ No newline at end of file
return
False
modules/my_validators.py
View file @
fa3ebedf
...
...
@@ -11,7 +11,6 @@ class IS_IN_USET(IS_IN_SET):
"""IS_IN_SET validator but working with unicode string.
"""
def
__init__
(
self
,
theset
,
**
kwargs
):
myset
=
[]
...
...
@@ -32,7 +31,6 @@ class IS_IN_USET(IS_IN_SET):
IS_IN_SET
.
__init__
(
self
,
myset
,
**
kwargs
)
def
__call__
(
self
,
value
):
if
isinstance
(
value
,
unicode
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment