Beispiel #1
0
    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
Beispiel #2
0
 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
Beispiel #3
0
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()
Beispiel #4
0
 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
Beispiel #5
0
 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
Beispiel #6
0
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()
Beispiel #7
0
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()
Beispiel #8
0
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()
Beispiel #9
0
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()
Beispiel #10
0
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()
Beispiel #11
0
 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
Beispiel #12
0
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()
Beispiel #13
0
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()
Beispiel #14
0
    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
Beispiel #15
0
    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
Beispiel #16
0
 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('&#x2191;'), XML('&#x2193;')),
            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)
Beispiel #18
0
 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(&#x27;#w2p_query_fields&#x27;).change();jQuery(&#x27;#w2p_query_panel&#x27;).slideDown();" type="text" value="" /><input class="btn btn-default" type="submit" value="Search" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_keywords&#x27;).val(&#x27;&#x27;);" type="submit" value="Clear" /></form><div id="w2p_query_panel" style="display:none;"><select class="form-control" id="w2p_query_fields" onchange="jQuery(&#x27;.w2p_query_row&#x27;).hide();jQuery(&#x27;#w2p_field_&#x27;+jQuery(&#x27;#w2p_query_fields&#x27;).val().replace(&#x27;.&#x27;,&#x27;-&#x27;)).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.id&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.id&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.id&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.first_name&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.first_name&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.first_name&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.last_name&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.last_name&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.last_name&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.email&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.email&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.email&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.username&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.username&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.username&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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=&amp;order=auth_user.id">Id</a></th><th class=""><a href="/a/c/f?keywords=&amp;order=auth_user.first_name">First name</a></th><th class=""><a href="/a/c/f?keywords=&amp;order=auth_user.last_name">Last name</a></th><th class=""><a href="/a/c/f?keywords=&amp;order=auth_user.email">E-mail</a></th><th class=""><a href="/a/c/f?keywords=&amp;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&amp;keywords=&amp;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&amp;keywords=&amp;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&amp;keywords=&amp;order=" title="HTML export of visible columns">HTML</a><a class="btn btn-default" href="/a/c/f?_export_type=json&amp;keywords=&amp;order=" title="JSON export of visible columns">JSON</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv&amp;keywords=&amp;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&amp;keywords=&amp;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&amp;keywords=&amp;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(&#x27;#w2p_query_fields&#x27;).change();jQuery(&#x27;#w2p_query_panel&#x27;).slideDown();" type="text" value="" /><input class="btn btn-default" type="submit" value="Search" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_keywords&#x27;).val(&#x27;&#x27;);" type="submit" value="Clear" /></form><div id="w2p_query_panel" style="display:none;"><select class="form-control" id="w2p_query_fields" onchange="jQuery(&#x27;.w2p_query_row&#x27;).hide();jQuery(&#x27;#w2p_field_&#x27;+jQuery(&#x27;#w2p_query_fields&#x27;).val().replace(&#x27;.&#x27;,&#x27;-&#x27;)).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.id&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.id&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.id&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.first_name&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.first_name&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.first_name&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.last_name&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.last_name&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.last_name&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.email&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.email&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.email&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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="&lt;">&lt;</option><option value="&gt;">&gt;</option><option value="&lt;=">&lt;=</option><option value="&gt;=">&gt;=</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(&#x27;new&#x27;,&#x27;auth_user.username&#x27;)" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;and&#x27;,&#x27;auth_user.username&#x27;)" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query(&#x27;or&#x27;,&#x27;auth_user.username&#x27;)" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery(&#x27;#w2p_query_panel&#x27;).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=&amp;order=auth_user.id">Id</a></th><th class=""><a href="/a/c/f?keywords=&amp;order=auth_user.first_name">First name</a></th><th class=""><a href="/a/c/f?keywords=&amp;order=auth_user.last_name">Last name</a></th><th class=""><a href="/a/c/f?keywords=&amp;order=auth_user.email">E-mail</a></th><th class=""><a href="/a/c/f?keywords=&amp;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&amp;keywords=&amp;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&amp;keywords=&amp;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&amp;keywords=&amp;order=" title="HTML export of visible columns">HTML</a><a class="btn btn-default" href="/a/c/f?_export_type=json&amp;keywords=&amp;order=" title="JSON export of visible columns">JSON</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv&amp;keywords=&amp;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&amp;keywords=&amp;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&amp;keywords=&amp;order=" title="XML export of columns shown">XML</a></div></div>')
Beispiel #20
0
def hae_kurssin_kurssityot(kurssi_id, db):
    #haetaan tietokannasta kaikki kurssin kurssityöt
    query = (kurssi_id==db.kurssityo.kurssi_id)
    return SQLFORM.grid(query)
Beispiel #21
0
 def test_grid(self):
     grid_form = SQLFORM.grid(self.db.auth_user)
     self.assertEqual(grid_form.xml()[:4], b'<div')