Skip to content

Commit

Permalink
added links feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rif committed Sep 18, 2012
1 parent 7275e8f commit 05c784d
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 203 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ plugins.web2admin.headers is a dictionary that maps 'tablename.fieldname' into t

plugins.web2admin.headers = {'student.last_name': T('Surname')}

plugins.web2admin.orderby is a dictionary that is used to set the default ordering for the table rows:

plugins.web2admin.orderby = {'student': db.student.last_name}

### Multi-database support

Expand Down Expand Up @@ -101,3 +104,17 @@ To define a new action you must create a function that take as arguments a table
If you want to disable the default actions or you want no actions at all (if you did not create any), you can set the plugins.web2admin.default_actions parameter to an empty dictionary.

plugins.web2admin.default_actions={}

### Custom column links
plugins.web2admin.links is used to display new columns which can be links to other pages. The links argument must be a dictionary linking a tablename to a list of dict(header='name',body=lambda row: A(...)) where header is the header of the new column and body is a function that takes a row and returns a value. In the example, the value is a A(...) helper.

plugins.web2admin.links = {'student':[
dict(header=T('hello'), body=lambda row: A('click me', _href=URL('default', 'hello', args=row.id))),
dict(header=T('foo'), body=lambda row: A('bar', _href=URL('default', 'foo', args=row.id))),
]}
### Left join

plugins.web2admin.left is an optional left join expressions used to build ...select(left=...). It has the value of a dictionary linking the table name and the join expression, for example:

plugins.web2admin.left = {'student': db.student.on(db.test.id)}
3 changes: 3 additions & 0 deletions controllers/plugin_web2admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ def view_table():
form = SQLFORM.factory(Field('action', requires=IS_IN_SET(actions.keys()))) if actions else None
grid = SQLFORM.smartgrid(w2a_db[table],args=request.args[:1],
fields = plugins.web2admin.fields[table] if table in plugins.web2admin.fields else None,
details = check_access(table, 'w2a_read'),
create = check_access(table, 'w2a_create'),
searchable = check_access(table, 'w2a_select'),
editable = check_access(table, 'w2a_edit'),
deletable = check_access(table, 'w2a_delete'),
csv = check_access(table, 'w2a_export'),
links = plugins.web2admin.links.get(table),
#left = db.student.on(db.test.id),
paginate = plugins.web2admin.items_per_page,
selectable = None if not actions else lambda ids: action_dispatch(table, ids, request.vars.action),
oncreate = lambda form: history_callback(table, form, 'created'),
onupdate = lambda form: history_callback(table, form, 'updated'),
ondelete = lambda table, record_id: history_callback(table, record_id, 'deleted'),
headers = plugins.web2admin.headers,
orderby = plugins.web2admin.orderby.get(table)

)
return locals()
Expand Down
2 changes: 2 additions & 0 deletions models/plugin_web2admin/plugin_web2admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def clone_action(table, ids):
'clone': clone_action},
actions = {},
fields = {},
links = {},
dbs = (db,),
headers = {},
orderby = {},
)
plugins.web2admin.actions.update(plugins.web2admin.default_actions)

Expand Down
4 changes: 2 additions & 2 deletions static/plugin_web2admin/css/bootstrap-responsive.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions static/plugin_web2admin/css/bootstrap.min.css

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions static/plugin_web2admin/css/web2py.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fieldset {padding:16px; border-top:1px #DEDEDE solid}
fieldset legend {text-transform:uppercase; font-weight:bold; padding:4px 16px 4px 16px; background:#f1f1f1}

/* fix ie problem with menu */
.ie-lte7 .topbar .container {z-index:2}

td.w2p_fw {padding-bottom:1px}
td.w2p_fl,td.w2p_fw,td.w2p_fc {vertical-align:top}
Expand Down Expand Up @@ -295,16 +296,10 @@ li.w2p_grid_breadcrumb_elem {
.web2py_console input, .web2py_console select,
.web2py_console a { margin: 2px; }

.ie9 #w2p_query_panel {padding-bottom:2px}

#wiki_page_body {
width: 600px;
height: auto;
min-height: 400px;
}

/* fix some IE problems */

.ie-lte7 .topbar .container {z-index:2}
.ie-lte8 div.flash{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#222222', endColorstr='#000000', GradientType=0 ); }
.ie-lte8 div.flash:hover {filter:alpha(opacity=25);}
.ie9 #w2p_query_panel {padding-bottom:2px}
}
Loading

0 comments on commit 05c784d

Please sign in to comment.