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
limbra
limbra
Commits
4d708b04
Commit
4d708b04
authored
Sep 28, 2015
by
LE GAC Renaud
Browse files
Fix warnings / errors in modules.
parent
172102fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
41 deletions
+43
-41
modules/callbacks.py
modules/callbacks.py
+10
-10
modules/check_tools.py
modules/check_tools.py
+9
-10
modules/reporting_tools.py
modules/reporting_tools.py
+24
-21
No files found.
modules/callbacks.py
View file @
4d708b04
...
...
@@ -13,22 +13,22 @@ from plugin_dbui import (CALLBACK_ERRORS,
get_where_query
)
def
INHIBIT_CASCADE_DELETE
(
set
):
def
INHIBIT_CASCADE_DELETE
(
set
_records
):
"""Inhibit the delete when publications use the reference field.
@type set: gluon.dal.Set
@param set:
@type set
_records
: gluon.dal.Set
@param set
_records
:
@rtype: bool
@return:
"""
db
,
T
=
current
.
globalenv
[
'db'
],
current
.
T
field
=
set
.
query
.
first
field
=
set
_records
.
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
!=
set
_records
.
query
.
op
:
return
False
# protection
...
...
@@ -48,7 +48,7 @@ def INHIBIT_CASCADE_DELETE(set):
# inhibit the delete if publications use the reference field
query
=
get_where_query
(
db
.
publications
)
query
=
(
query
)
&
(
set
.
query
)
query
=
(
query
)
&
(
set
_records
.
query
)
if
db
(
query
).
count
():
field
.
_table
[
CALLBACK_ERRORS
]
=
\
...
...
@@ -187,8 +187,8 @@ def INHIBIT_PUBLICATION_DELETE_ON_OK(s):
if
s
.
query
.
first
is
not
db
.
publications
.
id
:
return
False
id
=
s
.
query
.
second
if
db
.
publications
[
id
].
id_status
==
id_ok
:
id
_rec
=
s
.
query
.
second
if
db
.
publications
[
id
_rec
].
id_status
==
id_ok
:
db
.
publications
[
CALLBACK_ERRORS
]
=
\
T
(
"Can't delete a publication marked OK."
)
return
True
...
...
@@ -217,9 +217,9 @@ def INHIBIT_PUBLICATION_UPDATE_ON_OK(s, f):
if
s
.
query
.
first
is
not
db
.
publications
.
id
:
return
False
id
=
s
.
query
.
second
id
_rec
=
s
.
query
.
second
if
db
.
publications
[
id
].
id_status
==
id_ok
:
if
db
.
publications
[
id
_rec
].
id_status
==
id_ok
:
db
.
publications
[
CALLBACK_ERRORS
]
=
\
T
(
"Can't updated a publication marked OK."
)
return
True
...
...
modules/check_tools.py
View file @
4d708b04
...
...
@@ -10,7 +10,6 @@ import regex
from
gluon
import
current
from
plugin_dbui
import
(
UNDEF
,
UNDEF_ID
,
get_id
,
get_where_query
)
...
...
@@ -198,12 +197,12 @@ def extend_ids(db, query, ids):
corresponding to the C{query}. The id are unique in the list.
"""
set
=
db
(
query
)
if
set
.
count
():
for
row
in
set
.
select
():
id
=
str
(
row
.
publications
.
id
)
if
id
not
in
ids
:
ids
.
append
(
id
)
set
_records
=
db
(
query
)
if
set
_records
.
count
():
for
row
in
set
_records
.
select
():
id
_rec
=
str
(
row
.
publications
.
id
)
if
id
_rec
not
in
ids
:
ids
.
append
(
id
_rec
)
def
duplicate_article
(
publication
):
...
...
@@ -324,10 +323,10 @@ def duplicate_origin(publication):
# look for publication with the same origin field
query
=
db
.
publications
.
id
!=
publication
[
'id'
]
query
=
((
query
)
&
(
db
.
publications
.
origin
==
publication
[
'origin'
]))
set
=
db
(
query
)
set
_records
=
db
(
query
)
if
set
.
count
():
for
row
in
set
.
select
():
if
set
_records
.
count
():
for
row
in
set
_records
.
select
():
ids
.
append
(
str
(
row
.
id
))
return
ids
...
...
modules/reporting_tools.py
View file @
4d708b04
...
...
@@ -3,12 +3,15 @@
@author: R. Le Gac
"""
from
list_postprocessing
import
*
from
gluon
import
current
import
re
from
list_postprocessing
import
(
clean
,
highlight_my_authors
,
highlight_my_speaker
,
remove_undef
)
from
gluon.dal
import
smart_query
from
gluon.html
import
IFRAME
,
URL
from
gluon.storage
import
Storage
from
plugin_dbui
import
decode_field
,
UNDEF
def
format_publication
(
template
,
record
,
funcs
=
[]):
...
...
@@ -38,11 +41,11 @@ def format_publication(template, record, funcs=[]):
return
value
def
get_converter
(
list
):
def
get_converter
(
row
):
"""Get the converter dictionary for the axis label of the C{list}.
@type
list
: gluon.dal.Row
@param
list
: One row of the database table C{list}.
@type
row
: gluon.dal.Row
@param
row
: One row of the database table C{list}.
@rtype: dict
@return:
...
...
@@ -50,9 +53,9 @@ def get_converter(list):
"""
di
=
{}
if
list
.
axis_label_converters
:
if
row
.
axis_label_converters
:
s
=
re
.
sub
(
r
'" *, *'
,
'"|'
,
list
.
axis_label_converters
)
s
=
re
.
sub
(
r
'" *, *'
,
'"|'
,
row
.
axis_label_converters
)
for
el
in
s
.
split
(
'|'
):
m
=
re
.
match
(
r
' *(.+) *: *"(.+)"'
,
el
)
...
...
@@ -62,7 +65,7 @@ def get_converter(list):
return
di
def
get_sections
(
db
,
selector
,
list
):
def
get_sections
(
db
,
selector
,
row
):
"""Get the section rows for the C{list}.
@type db: gluon.dal.DAL
...
...
@@ -71,8 +74,8 @@ def get_sections(db, selector, list):
@type selector: plugin_dbui.Selector
@param selector:
@type
list
: gluon.dal.Row
@param
list
: One row of the database table C{list}.
@type
row
: gluon.dal.Row
@param
row
: One row of the database table C{list}.
@rtype: list
@return:
...
...
@@ -84,7 +87,7 @@ def get_sections(db, selector, list):
"""
sections
=
[]
for
el
in
list
.
sections
.
split
(
','
):
for
el
in
row
.
sections
.
split
(
','
):
# retrieve the section record
el
=
el
.
strip
()
...
...
@@ -130,18 +133,18 @@ def get_sections(db, selector, list):
section
.
query
=
query
# order by directive to order publication for this section
# taking into account directive from the
list
and from the section
# taking into account directive from the
row
and from the section
orderby
=
[]
for
level
in
(
'level_1'
,
'level_2'
,
'level_3'
,
'level_4'
):
axis
=
'axis_%s'
%
level
if
not
list
[
axis
]:
if
not
row
[
axis
]:
continue
tablename
=
list
[
axis
]
fieldname
=
list
[
'granularity_%s'
%
level
]
direction
=
list
[
"direction_%s"
%
level
]
tablename
=
row
[
axis
]
fieldname
=
row
[
'granularity_%s'
%
level
]
direction
=
row
[
"direction_%s"
%
level
]
field
=
db
[
tablename
][
fieldname
]
if
direction
==
"DESC"
:
...
...
@@ -178,14 +181,14 @@ def ref_url(name='List'):
@return: C{"http://..."}
"""
vars
=
[]
li
=
[]
for
(
k
,
v
)
in
request
.
vars
.
iteritems
():
if
k
.
startswith
(
name
)
and
len
(
v
):
vars
.
append
(
"%s=%s"
%
(
k
,
v
))
li
.
append
(
"%s=%s"
%
(
k
,
v
))
pass
pass
t
=
(
request
.
env
.
http_host
,
request
.
env
.
path_info
,
'&'
.
join
(
vars
))
t
=
(
request
.
env
.
http_host
,
request
.
env
.
path_info
,
'&'
.
join
(
li
))
url
=
"http://%s%s?%s"
%
t
return
url
...
...
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