Skip to content

Commit

Permalink
renamed reserved SQl keyword action, thanks rochacbruno
Browse files Browse the repository at this point in the history
  • Loading branch information
rif committed Oct 11, 2012
1 parent d0777ea commit b78d86b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
3 changes: 2 additions & 1 deletion controllers/plugin_web2admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def view_table():
)
w2a_filters = []
for fltr in plugins.web2admin.filters:
if fltr.table._tablename == table: w2a_filters.append(fltr)
if fltr.name in w2a_db[table].fields:
w2a_filters.append(fltr)
return locals()

@auth.requires_login()
Expand Down
36 changes: 18 additions & 18 deletions models/plugin_web2admin/plugin_web2admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def cdb(index=-1):
w2a_def_db = cdb(0)

w2a_def_db.define_table('plugin_web2admin_history',
Field('action'),
Field('w2a_action'),
auth.signature
)
w2a_history = w2a_def_db.plugin_web2admin_history
Expand All @@ -75,7 +75,7 @@ def action_dispatch(table, ids, action):
else:
if action:
plugins.web2admin.actions[action](table,ids)
w2a_history.insert(action=T('executed action %s on %s id(s): %s') % (action, table, ids))
w2a_history.insert(w2a_action=T('executed action %s on %s id(s): %s') % (action, table, ids))
else:
session.flash=T('Please select an action')

Expand All @@ -94,6 +94,7 @@ def history_callback(table, form, action):

def get_filter_links(field):
"""Return filter links for specified field"""
links = []
return {
'datetime': datetime_filter,
'date': datetime_filter,
Expand All @@ -106,29 +107,28 @@ def get_filter_links(field):

def bool_filter(field):
table = field.table._tablename
return map(LI, (
SPAN(T('By %s' % field.name), _class="muted"),
A(T('All'), _href=URL('plugin_web2admin', 'view_table',
args=table)),
A(T('Yes'), _href=URL('plugin_web2admin', 'view_table',
args=(table, table),
vars={'keywords':'%s="T"' % str(field)})),
A(T('No'), _href=URL('plugin_web2admin', 'view_table',
args=(table, table),
vars={'keywords':'%s="F"' % str(field)}))
))
return LI([
SPAN(T('By %s' % field.name), _class="muted"),
A(T('All'), _href=URL('plugin_web2admin', 'view_table',
args=table)),
A(T('Yes'), _href=URL('plugin_web2admin', 'view_table',
args=(table, table),
vars={'keywords':'%s="T"' % str(field)})),
A(T('No'), _href=URL('plugin_web2admin', 'view_table',
args=(table, table),
vars={'keywords':'%s="F"' % str(field)}))
])

def number_filter(field):
table = field.table._tablename
max = field.max()
max = db().select(max, cacheable=True).first()[max]
min = field.min()
min = db().select(min, cacheable=True).first()[min]
if not max or not min: return ''
med = (max-min)/2
low_quarter = med/2
high_quarter = med + low_quarter
return map(LI, (
return LI([
SPAN(T('By %s' % field.name), _class="muted"),
A(T('All'), _href=URL('plugin_web2admin', 'view_table', args=table)),
A(T('Less than %d' % low_quarter),
Expand All @@ -153,7 +153,7 @@ def number_filter(field):
args=(table, table),
vars={'keywords':'%s>="%d"' % (
str(field), high_quarter)}))
))
])

def string_filter(field):
import string
Expand All @@ -174,7 +174,7 @@ def datetime_filter(field):
table = field.table._tablename
today = datetime.date.today()
seven_days_ago = today - datetime.timedelta(7)
return map(LI, (
return LI([
SPAN(T('By %s' % field.name), _class="muted"),
A(T('Any date'), _href=URL('plugin_web2admin', 'view_table',
args=table)),
Expand All @@ -193,4 +193,4 @@ def datetime_filter(field):
vars={'keywords':'%s>"%s-01-01"' % (
str(field),
today.strftime('%Y'))}))
))
])
2 changes: 1 addition & 1 deletion views/plugin_web2admin/history.load
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<li class="nav-header">{{=T('History')}}</li>
{{for log in logs:}}
{{u = db.auth_user(log.created_by)}}
<li class="muted" style="font-size: 95%">{{='%(first_name)s %(last_name)s' % u}} {{=log.action}}, {{=prettydate(log.created_on,T)}}</li>
<li class="muted" style="font-size: 95%">{{='%(first_name)s %(last_name)s' % u}} {{=log.w2a_action}}, {{=prettydate(log.created_on,T)}}</li>
{{pass}}

10 changes: 3 additions & 7 deletions views/plugin_web2admin/w2a_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@
<!-- Filters -->
{{if 'w2a_filters' in globals() and w2a_filters:}}
<li class="nav-header">{{=T('filters')}}</li>
{{
for fltr in w2a_filters:
for li in get_filter_links(fltr):
=li
pass
pass
}}
{{for fltr in w2a_filters:}}
{{=get_filter_links(fltr)}}
{{pass}}
{{pass}}
<!-- External links -->
{{if plugins.web2admin.custom_sidebar_title and plugins.web2admin.custom_sidebar_links:}}
Expand Down

0 comments on commit b78d86b

Please sign in to comment.