Created
February 9, 2012 19:10
-
-
Save ralphbean/1782150 to your computer and use it in GitHub Desktop.
working on pyramid views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # view | |
| @view_config(route_name="user_form", renderer="admin/user.html") | |
| def user_form(request): | |
| w = widgets.UserForm | |
| w.fetch_data(request) | |
| mw = tw2.core.core.request_local()['middleware'] | |
| mw.controllers.register(w.req(), 'user_submit') | |
| return {'widget': w} | |
| @view_config(route_name="user_grid", renderer="admin/user.html") | |
| def user_grid(request): | |
| w = widgets.UserGrid.req() | |
| mw = tw2.core.core.request_local()['middleware'] | |
| mw.controllers.register(w, 'user_grid') | |
| return {'widget': w} | |
| # widgets | |
| class UserForm(tw2.sqla.DbFormPage): | |
| entity = models.User | |
| #resources = [tw2.core.CSSLink(link='static/css/style.css')] | |
| redirect = '/admin/user/grid' | |
| title = 'User' | |
| class child(tw2.dynforms.CustomisedTableForm): | |
| action = '/tw2_controllers/user_submit' | |
| id = tw2.forms.HiddenField() | |
| username = tw2.forms.TextField(validator=tw2.core.Required) | |
| password = tw2.forms.TextField() | |
| groups = tw2.sqla.DbCheckBoxList(entity=models.Group) | |
| #class cast(tw2.dynforms.GrowingGridLayout): | |
| # character = tw2.forms.TextField() | |
| # actor = tw2.forms.TextField() | |
| class UserGrid(tw2.jqplugins.jqgrid.SQLAjqGridWidget): | |
| id = 'user_grid' | |
| entity = models.User | |
| excluded_columns = ['id', 'password', '_password'] | |
| prmFilter = {'stringResult': True, 'searchOnEnter': False} | |
| pager_options = { "search" : False, "refresh" : True, "add" : False } | |
| options = { | |
| 'url': '/tw2_controllers/user_grid/', | |
| 'rowNum': 15, | |
| 'rowList':[15,30,50], | |
| 'viewrecords': True, | |
| 'imgpath': 'static/jqGrid/themes/green/images', | |
| 'width': 'auto', | |
| 'height': 'auto', | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment