Commit 4d708b04 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Fix warnings / errors in modules.

parent 172102fc
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment