def grid(self): def get_unique(form): slug = IS_SLUG()(form.vars.f_title)[0] form.vars.f_slug_key = slug fields = [self.db.t_page.f_title, self.db.t_page.f_lang_code, self.db.t_page.f_tags, self.db.t_page.f_is_active] links = [ lambda row: A('Preview', _target='_blank', _class="btn-success btn-mini", _href=URL('page', 'show', args=[str(row.id)]))] grid = SQLFORM.grid(self.db.t_page, ui='web2py', fields=fields, #orderby=fields[-2], links=links, csv=False, searchable=True, create=True, details=True, editable=True, deletable=True, onvalidation=get_unique, #oncreate=get_unique, ) return grid
def get_form(self, query,field_id,orderby,fields=None,headers={},frm_type="view",priority="0,1",create=True): gform = SQLFORM.grid(query=query, field_id=field_id, fields=fields, headers=headers, orderby=orderby, paginate=20, maxtextlength=25, searchable=False, csv=False, details=False, showbuttontext=False, create=create, deletable=False, editable=True, selectable=False, ignore_common_filters=False) if type(gform[1][0][0]).__name__!="TABLE": if frm_type in ("edit","new"): gform = self.set_input_form(gform) if frm_type == "edit": gform[1][0][0] = "" else: htable = gform.elements("div.web2py_htmltable") if len(htable)>0: self.set_htmltable_style(htable[0][0],"form_search",priority) htable[0][0]["_width"]="100%" counter = gform.elements("div.web2py_counter") if len(counter)>0: if counter[0][0]==None: counter[0][0] = "" if gform[len(gform)-1]["_class"].startswith("web2py_paginator"): pages = gform[len(gform)-1].elements("a") for i in range(len(pages)): pages[i]["_data-ajax"] = "false" return gform
def confirm_vacation(): db.co_vacation.id.readable = False subordinates = db(db.co_employee.superior == db(db.co_employee.authuser == auth.user.id).select(db.co_employee.id).first().id).select() vacations = SQLFORM.grid(db.co_vacation.employee.belongs(subordinates) & (db.co_vacation.status == 'Awaiting'), orderby = ~db.co_vacation.startdate, create = False, details = False, editable = False, deletable = False, links = [lambda row: A(T('Accept'), _href = URL('accept_vacation', args = row.id), _class = 'btn'), lambda row: A(T('Reject'), _href = URL('reject_vacation', args = row.id), _class = 'btn')]) return locals()
def grid(self): grid = SQLFORM.grid(self.db.t_post, formstyle='table2cols', csv=False, searchable=False, create=True, details=True, editable=True, deletable=True, ) return grid
def grid(self): grid = SQLFORM.grid( self.db.t_post, formstyle='table2cols', csv=False, searchable=False, create=True, details=True, editable=True, deletable=True, ) return grid
def users(): if "new" in request.args: redirect(URL("user", args=("new"))) elif "edit" in request.args: redirect(URL("user", args=("edit", request.args(2)))) elif "view" in request.args: redirect(URL("user", args=("view", request.args(2)))) else: db.auth_user.id.readable = False grid = SQLFORM.grid(db.auth_user, orderby=db.auth_user.last_name, maxtextlength=50) return locals()
def memberships(): if "new" in request.args: redirect(URL("membership", args=("new"))) elif "edit" in request.args: redirect(URL("membership", args=("edit", request.args(2)))) elif "view" in request.args: redirect(URL("membership", args=("view", request.args(2)))) else: db.auth_membership.id.readable = False grid = SQLFORM.grid(db.auth_membership, maxtextlength=50) return locals()
def groups(): if "new" in request.args: redirect(URL("group", args=("new"))) elif "edit" in request.args: redirect(URL("group", args=("edit", request.args(2)))) elif "view" in request.args: redirect(URL("group", args=("view", request.args(2)))) else: db.auth_group.id.readable = False grid = SQLFORM.grid(db.auth_group, orderby=db.auth_group.role, maxtextlength=50) return locals()
def list_task(): if 'new' in request.args: redirect(URL('create_task', args = ('new', request.args(0)))) elif 'edit' in request.args: redirect(URL('update_task', args = ('edit', request.args(3)))) elif 'view' in request.args: redirect(URL('view_task', args = ('view', request.args(3)))) else: projectid = request.args(0, cast = int) projectname = db.co_project(projectid).name db.co_task.id.readable = False tasks = SQLFORM.grid(db.co_task.project == projectid, orderby = ~db.co_task.modified_on, args = [projectid], maxtextlength = 50, user_signature = False) return locals()
def list_project(): if 'new' in request.args: redirect(URL('create_project', args = ('new'))) elif 'edit' in request.args: redirect(URL('update_project', args = ('edit', request.args(2)))) elif 'view' in request.args: redirect(URL('view_project', args = ('view', request.args(2)))) else: db.co_project.id.readable = False db.co_project.budget.readable = False db.co_project.managers.readable = False db.co_project.architects.readable = False db.co_project.analysts.readable = False db.co_project.programmers.readable = False db.co_project.testers.readable = False projects = SQLFORM.grid(db.co_project, orderby = ~db.co_project.startdate, maxtextlength = 50) return locals()
def get_form(self, query, field_id, orderby, fields=None, headers={}, frm_type="view", priority="0,1", create=True): gform = SQLFORM.grid(query=query, field_id=field_id, fields=fields, headers=headers, orderby=orderby, paginate=20, maxtextlength=25, searchable=False, csv=False, details=False, showbuttontext=False, create=create, deletable=False, editable=True, selectable=False, ignore_common_filters=False) if type(gform[1][0][0]).__name__ != "TABLE": if frm_type in ("edit", "new"): gform = self.set_input_form(gform) if frm_type == "edit": gform[1][0][0] = "" else: htable = gform.elements("div.web2py_htmltable") if len(htable) > 0: self.set_htmltable_style(htable[0][0], "form_search", priority) htable[0][0]["_width"] = "100%" counter = gform.elements("div.web2py_counter") if len(counter) > 0: if counter[0][0] == None: counter[0][0] = "" if gform[len(gform) - 1]["_class"].startswith("web2py_paginator"): pages = gform[len(gform) - 1].elements("a") for i in range(len(pages)): pages[i]["_data-ajax"] = "false" return gform
def list_vacation(): if 'new' in request.args: redirect(URL('create_vacation', args=('new'))) elif 'edit' in request.args: redirect(URL('update_vacation', args=('edit', request.args(2)))) elif 'view' in request.args: redirect(URL('view_vacation', args=('view', request.args(2)))) else: db.co_vacation.id.readable = False db.co_vacation.employee.readable = False vacations = SQLFORM.grid(db.co_vacation.created_by == auth.user.id, orderby = ~db.co_vacation.startdate, editable = lambda row: (row.status == 'Awaiting'), deletable = lambda row: (row.status == 'Awaiting')) totalthisyear = db(db.co_employee.authuser == auth.user.id).select().first().cyvacationdays totallastyear = db(db.co_employee.authuser == auth.user.id).select().first().pyvacationdays previousyearleft = totallastyear - (db((db.co_vacation.startdate.year() == datetime.date.today().year - 1) & (db.co_vacation.status == 'Accepted')).select(db.co_vacation.totaldays.sum()).first()[db.co_vacation.totaldays.sum()] or 0) utilized = db((db.co_vacation.created_by == auth.user.id) & (db.co_vacation.status == 'Accepted')).select(db.co_vacation.totaldays.sum()).first()[db.co_vacation.totaldays.sum()] return locals()
def list_employee(): if 'new' in request.args: redirect(URL('create_employee', args=('new'))) elif 'edit' in request.args: redirect(URL('update_employee', args=('edit', request.args(2)))) elif 'view' in request.args: redirect(URL('view_employee', args=('view', request.args(2)))) else: db.co_employee.id.readable = False db.co_employee.came.readable = False db.co_employee.gone.readable = False db.co_employee.address.readable = False db.co_employee.superior.readable = False db.co_employee.renumeration.readable = False db.co_employee.cyvacationdays.readable = False db.co_employee.pyvacationdays.readable = False employees = SQLFORM.grid(db.co_employee, orderby = db.co_employee.lastname) return locals()
def grid(self): fields = [self.db.t_apps.f_title, self.db.t_apps.f_is_active, self.db.t_apps.f_order_id] fields[1].represent = lambda value, row: SPAN('active', _class='label label-success') \ if value == True else SPAN('disable', _class='label label-danger') links = [ lambda row: A('Enable', _class="btn-success btn-mini", callback=URL('apps', 'action', args=[str(row.id), 'enable'])) if row.f_is_active == False else "", lambda row: A('Disable', _class="btn-danger btn-mini", callback=URL('apps', 'action', args=[str(row.id), 'disable'])) if row.f_is_active == True else "",] self.db.t_apps.f_thumbnail.readable = True grid = SQLFORM.grid(self.db.t_apps, ui='web2py', fields=fields, links=links, csv=False, searchable=True) return grid
def grid(self): links = [ lambda row: A('Preview', _target='_blank', _class="btn-success btn-mini", _href=URL('template', 'show', args=[str(row.id)]))] fields = [self.db.t_email_template.f_template_key, self.db.t_email_template.f_lang_code, self.db.t_email_template.f_attachment_file] grid = SQLFORM.grid(self.db.t_email_template, ui='web2py', #linked_tables=linked_tables, fields=fields, #orderby=fields[-2], links=links, csv=False, searchable=False, create=True, details=True, editable=True, deletable=True, #onvalidation=get_unique, #oncreate=get_unique, ) return grid
def test_grid(self): grid_form = SQLFORM.grid(self.db.auth_user) self.assertEqual(grid_form.xml()[:4], b'<div')
def do_grid_select(self): response = current.response request = current.request T = current.T action = 'select' response.title = T(self.table._plural) response.subtitle = T('Listing') response.breadcrumbs = response.title exportclasses = dict( csv_with_hidden_cols=False, json=False, tsv_with_hidden_cols=False, tsv=False ) links = self.grid_links() def _table_or_query(): query = self.customize.on_grid_query(self) if not query: query = self.table return query self.customize.on_before_init(self, action) grid = SQLFORM.grid( _table_or_query(), fields=self.customize.on_fields_list(self, action), #field_id=None, #left=None, #headers={}, orderby=self.customize.on_grid_orderby(self), #groupby=None, #searchable=True, #sortable=True, #paginate=20, deletable=False, editable=False, details=False, #selectable=None, #create=True, #csv=True, links=links, #links_in_grid=True, #upload='<default>', #args=[], #user_signature=True, #maxtextlengths={}, maxtextlength=30, #onvalidation=None, #oncreate=None, #onupdate=None, #ondelete=None, #sorter_icons=(XML('↑'), XML('↓')), ui=ONXFORM.ui, #showbuttontext=True, _class="table table-condensed table-hover resp-table", #formname='web2py_grid', #search_widget='default', #ignore_rw = False, #formstyle = 'table3cols', exportclasses=exportclasses, #formargs={}, #createargs={'origin':'select'}, #editargs={}, #viewargs={}, #buttons_placement = 'right', #links_placement = 'right', ) self.customize.on_after_init(self, grid, action) return dict(content=grid)
def test_grid(self): grid_form = SQLFORM.grid(self.db.auth_user) self.assertEqual(grid_form.xml(), b'<div class="web2py_grid "><div class="web2py_console "><form action="/a/c/f" enctype="multipart/form-data" method="GET"><input class="form-control" id="w2p_keywords" name="keywords" onfocus="jQuery('#w2p_query_fields').change();jQuery('#w2p_query_panel').slideDown();" type="text" value="" /><input class="btn btn-default" type="submit" value="Search" /><input class="btn btn-default" onclick="jQuery('#w2p_keywords').val('');" type="submit" value="Clear" /></form><div id="w2p_query_panel" style="display:none;"><select class="form-control" id="w2p_query_fields" onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();" style="float:left"><option value="auth_user.id">Id</option><option value="auth_user.first_name">First name</option><option value="auth_user.last_name">Last name</option><option value="auth_user.email">E-mail</option><option value="auth_user.username">Username</option></select><div class="w2p_query_row" id="w2p_field_auth_user-id" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="in">in</option><option value="not in">not in</option></select><input class="id form-control" id="w2p_value_auth_user-id" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.id')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.id')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.id')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-first_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-first_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.first_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.first_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.first_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-last_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-last_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.last_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.last_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.last_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-email" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-email" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.email')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.email')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.email')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-username" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-username" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.username')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.username')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.username')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div></div><script><!--\n\n jQuery(\'#w2p_query_fields input,#w2p_query_fields select\').css(\n \'width\',\'auto\');\n jQuery(function(){web2py_ajax_fields(\'#w2p_query_fields\');});\n function w2p_build_query(aggregator,a) {\n var b=a.replace(\'.\',\'-\');\n var option = jQuery(\'#w2p_field_\'+b+\' select\').val();\n var value;\n var $value_item = jQuery(\'#w2p_value_\'+b);\n if ($value_item.is(\':checkbox\')){\n if ($value_item.is(\':checked\'))\n value = \'True\';\n else value = \'False\';\n }\n else\n { value = $value_item.val().replace(\'"\',\'\\\\"\')}\n var s=a+\' \'+option+\' "\'+value+\'"\';\n var k=jQuery(\'#w2p_keywords\');\n var v=k.val();\n if(aggregator==\'new\') k.val(s); else k.val((v?(v+\' \'+ aggregator +\' \'):\'\')+s);\n }\n \n//--></script><div class="web2py_counter">1 records found</div></div><div class="web2py_table"><div class="web2py_htmltable" style="width:100%;overflow-x:auto;-ms-overflow-x:scroll"><table><colgroup><col data-column="1" id="auth_user-id" /><col data-column="2" id="auth_user-first_name" /><col data-column="3" id="auth_user-last_name" /><col data-column="4" id="auth_user-email" /><col data-column="5" id="auth_user-username" /><col data-column="6" /></colgroup><thead><tr class=""><th class=""><a href="/a/c/f?keywords=&order=auth_user.id">Id</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.first_name">First name</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.last_name">Last name</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.email">E-mail</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.username">Username</a></th><th class=""></th></tr></thead><tbody><tr class="w2p_odd odd with_id" id="1"><td>1</td><td>Bart</td><td>Simpson</td><td>[email protected]</td><td>user1</td><td class="row_buttons" nowrap="nowrap"><a class="button btn btn-default" href="/a/c/f/view/auth_user/1"><span class="icon magnifier icon-zoom-in glyphicon glyphicon-zoom-in"></span> <span class="buttontext button" title="View">View</span></a></td></tr></tbody></table></div></div><div class="w2p_export_menu">Export:<a class="btn btn-default" href="/a/c/f?_export_type=csv&keywords=&order=" title="Comma-separated export of visible columns. Fields from other tables are exported as they appear on-screen but this may be slow for many rows">CSV</a><a class="btn btn-default" href="/a/c/f?_export_type=csv_with_hidden_cols&keywords=&order=" title="Comma-separated export including columns not shown; fields from other tables are exported as raw values for faster export">CSV (hidden cols)</a><a class="btn btn-default" href="/a/c/f?_export_type=html&keywords=&order=" title="HTML export of visible columns">HTML</a><a class="btn btn-default" href="/a/c/f?_export_type=json&keywords=&order=" title="JSON export of visible columns">JSON</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content, visible columns only. May be slow.">TSV (Spreadsheets)</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv_with_hidden_cols&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content including hidden columns. May be slow">TSV (Spreadsheets, hidden cols)</a><a class="btn btn-default" href="/a/c/f?_export_type=xml&keywords=&order=" title="XML export of columns shown">XML</a></div></div>')
def test_grid(self): grid_form = SQLFORM.grid(self.db.auth_user) self.assertEqual(grid_form.xml(), b'<div class="web2py_grid "><div class="web2py_console "><form action="/a/c/f" enctype="multipart/form-data" method="GET"><input class="form-control" id="w2p_keywords" name="keywords" onfocus="jQuery('#w2p_query_fields').change();jQuery('#w2p_query_panel').slideDown();" type="text" value="" /><input class="btn btn-default" type="submit" value="Search" /><input class="btn btn-default" onclick="jQuery('#w2p_keywords').val('');" type="submit" value="Clear" /></form><div id="w2p_query_panel" style="display:none;"><select class="form-control" id="w2p_query_fields" onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();" style="float:left"><option value="auth_user.id">Id</option><option value="auth_user.first_name">First name</option><option value="auth_user.last_name">Last name</option><option value="auth_user.email">E-mail</option><option value="auth_user.username">Username</option></select><div class="w2p_query_row" id="w2p_field_auth_user-id" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="in">in</option><option value="not in">not in</option></select><input class="id form-control" id="w2p_value_auth_user-id" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.id')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.id')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.id')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-first_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-first_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.first_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.first_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.first_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-last_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-last_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.last_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.last_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.last_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-email" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-email" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.email')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.email')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.email')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-username" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-username" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.username')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.username')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.username')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div></div><script><!--\n\n jQuery(\'#w2p_query_fields input,#w2p_query_fields select\').css(\n \'width\',\'auto\');\n jQuery(function(){web2py_ajax_fields(\'#w2p_query_fields\');});\n function w2p_build_query(aggregator,a) {\n var b=a.replace(\'.\',\'-\');\n var option = jQuery(\'#w2p_field_\'+b+\' select\').val();\n var value;\n var $value_item = jQuery(\'#w2p_value_\'+b);\n if ($value_item.is(\':checkbox\')){\n if ($value_item.is(\':checked\'))\n value = \'True\';\n else value = \'False\';\n }\n else\n { value = $value_item.val().replace(\'"\',\'\\\\"\')}\n var s=a+\' \'+option+\' "\'+value+\'"\';\n var k=jQuery(\'#w2p_keywords\');\n var v=k.val();\n if(aggregator==\'new\') k.val(s); else k.val((v?(v+\' \'+ aggregator +\' \'):\'\')+s);\n }\n \n//--></script><div class="web2py_counter">1 records found</div></div><div class="web2py_table"><div class="web2py_htmltable" style="width:100%;overflow-x:auto;-ms-overflow-x:scroll"><table><colgroup><col data-column="1" id="auth_user-id" /><col data-column="2" id="auth_user-first_name" /><col data-column="3" id="auth_user-last_name" /><col data-column="4" id="auth_user-email" /><col data-column="5" id="auth_user-username" /><col data-column="6" /></colgroup><thead><tr class=""><th class=""><a href="/a/c/f?keywords=&order=auth_user.id">Id</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.first_name">First name</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.last_name">Last name</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.email">E-mail</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.username">Username</a></th><th class=""></th></tr></thead><tbody><tr class="w2p_odd odd with_id" id="1"><td>1</td><td>Bart</td><td>Simpson</td><td>[email protected]</td><td>user1</td><td class="row_buttons" nowrap="nowrap"><a class="button btn btn-default" href="/a/c/f/view/auth_user/1"><span class="icon magnifier icon-zoom-in glyphicon glyphicon-zoom-in"></span> <span class="buttontext button" title="View">View</span></a></td></tr></tbody></table></div></div><div class="w2p_export_menu">Export:<a class="btn btn-default" href="/a/c/f?_export_type=csv&keywords=&order=" title="Comma-separated export of visible columns. Fields from other tables are exported as they appear on-screen but this may be slow for many rows">CSV</a><a class="btn btn-default" href="/a/c/f?_export_type=csv_with_hidden_cols&keywords=&order=" title="Comma-separated export including columns not shown; fields from other tables are exported as raw values for faster export">CSV (hidden cols)</a><a class="btn btn-default" href="/a/c/f?_export_type=html&keywords=&order=" title="HTML export of visible columns">HTML</a><a class="btn btn-default" href="/a/c/f?_export_type=json&keywords=&order=" title="JSON export of visible columns">JSON</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content, visible columns only. May be slow.">TSV (Spreadsheets)</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv_with_hidden_cols&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content including hidden columns. May be slow">TSV (Spreadsheets, hidden cols)</a><a class="btn btn-default" href="/a/c/f?_export_type=xml&keywords=&order=" title="XML export of columns shown">XML</a></div></div>')
def hae_kurssin_kurssityot(kurssi_id, db): #haetaan tietokannasta kaikki kurssin kurssityöt query = (kurssi_id==db.kurssityo.kurssi_id) return SQLFORM.grid(query)
def test_grid(self): grid_form = SQLFORM.grid(self.db.auth_user) self.assertEqual(grid_form.xml()[:4], b'<div')