1 | {{extend 'layout.html'}} |
---|
2 | {{ |
---|
3 | #grid['_class'] = 'web2py_grid' |
---|
4 | if not request.args: |
---|
5 | add_btn = grid.elements('div.web2py_console a.w2p_trap',replace=None)[0] |
---|
6 | add_btn['_id'] = 'w2p_grid_addbtn' |
---|
7 | add_btn['_class'] = 'w2p_trap btn' |
---|
8 | qry_pnl_rows = grid.elements('div',_class="w2p_query_row hidden") |
---|
9 | for qry_pnl_row in qry_pnl_rows: |
---|
10 | qry_pnl_btn1 = qry_pnl_row.elements('input',_value="New",replace=None)[0] |
---|
11 | qry_pnl_btn2 = qry_pnl_row.elements('input',_value="And",replace=None)[0] |
---|
12 | qry_pnl_btn3 = qry_pnl_row.elements('input',_value="Or",replace=None)[0] |
---|
13 | qry_pnl_btngrp = qry_pnl_row.elements('input',_value="Close",replace=lambda me:DIV(qry_pnl_btn1,qry_pnl_btn2,qry_pnl_btn3,me,_class="qry_pnl_btns")) |
---|
14 | pass |
---|
15 | qry_pnl = grid.elements('div#w2p_query_panel',replace=None) |
---|
16 | csl_frm = grid.elements('div.web2py_console form')[0] |
---|
17 | csl_frm['_class'] = 'form-inline' |
---|
18 | csl_frm_search = grid.elements('#web2py_keywords',replace=lambda me:DIV(me,TAG['button'](T('Search'),_class='btn',_type='submit'),TAG['button'](T('Clear'),_class='btn',_type='button',_onclick='jQuery("#web2py_keywords").val("");'),_class="input-append")) |
---|
19 | csl_frm_search_btn1 = grid.elements('input',_value="Search",replace=None) |
---|
20 | csl_frm_search_btn2 = grid.elements('input',_value="Clear",replace=None) |
---|
21 | new_console = grid.elements('div.web2py_console form',replace=lambda frm_csl:DIV(SPAN(add_btn,_class='span1'),SPAN(DIV(frm_csl,qry_pnl[0],_id='w2p_search-form'),_class='span5'),_class='row-fluid')) |
---|
22 | w2p_grid_tbl = grid.element('table') |
---|
23 | if w2p_grid_tbl: |
---|
24 | w2p_grid_tbl['_class'] = 'table table-condensed table-hover table-bordered' |
---|
25 | tbl_button_rows = grid.elements('td',_class="row_buttons") |
---|
26 | for tbl_button_row in tbl_button_rows: |
---|
27 | buttons = tbl_button_row.elements('a.w2p_trap') |
---|
28 | for button in buttons: |
---|
29 | button['_class'] = 'w2p_trap btn' |
---|
30 | pass |
---|
31 | pass |
---|
32 | export_menu = grid.element('div.w2p_export_menu') |
---|
33 | export_menu_links = export_menu.elements('a') |
---|
34 | export_menu_items = [] |
---|
35 | for link in export_menu_links: |
---|
36 | item = LI(link) |
---|
37 | export_menu_items.append(item) |
---|
38 | pass |
---|
39 | new_export_menu = DIV(A(T('Exports:'),SPAN(_class='caret'),_href='#',_class='btn dropdown-toggle',**{'_data-toggle':"dropdown"}),UL(*export_menu_items,_class='dropdown-menu'),_class='w2p_export_menu btn-group pull-left') |
---|
40 | grid_pagination = grid.element('div.web2py_paginator') |
---|
41 | if grid_pagination: |
---|
42 | export_menu = grid.element('div.w2p_export_menu',replace=None) |
---|
43 | new_grid_pagination = grid.element('div.web2py_paginator',replace=lambda me:DIV(new_export_menu,me,_class='w2p_grid_bottom_bar')) |
---|
44 | grid_pagination['_class'] = 'web2py_paginator pagination pagination-right' |
---|
45 | grid_page_active = grid.element('li.current') |
---|
46 | grid_page_active['_class'] = 'current active' |
---|
47 | else: |
---|
48 | new_grid_pagination = grid.element('div.w2p_export_menu',replace=DIV(new_export_menu)) |
---|
49 | pass |
---|
50 | records_counter = grid.element('div.web2py_counter') |
---|
51 | records_found = int(records_counter[0].partition('records')[0].strip()) |
---|
52 | paginate = 5 # TODO: get it from the controller |
---|
53 | pages = records_found/paginate |
---|
54 | tot_pages = pages if records_found%paginate == 0 else pages+1 |
---|
55 | current_page = int(request.vars.page) if request.vars.page else 1 |
---|
56 | end_record = paginate*current_page if current_page < tot_pages else records_found |
---|
57 | begin_record = 1 if current_page == 1 else (paginate*(current_page-1))+1 |
---|
58 | rec = "records" if records_found>1 else "record" |
---|
59 | record_shown_in_the_page = T("Showing %s to %s of %s %s found")%(begin_record,end_record,records_found,rec) |
---|
60 | new_record_counter = grid.element('div.web2py_counter',replace=DIV(record_shown_in_the_page,_class="web2py_counter span6 pull-right")) |
---|
61 | pass |
---|
62 | elif request.args(0)=='new': |
---|
63 | bck_btn = grid.element('div.web2py_grid span.leftarrow').parent |
---|
64 | bck_btn['_id'] = 'w2p_grid_bckbtn' |
---|
65 | bck_btn['_class'] = 'w2p_trap btn' |
---|
66 | frm = grid.element('div.web2py_grid form') |
---|
67 | frm['_class'] = 'web2py_form span4 well well-small' |
---|
68 | |
---|
69 | checkbox_lbl = frm.element('label',_for='auth_user_is_manager') |
---|
70 | checkbox_inp = frm.element(_name='is_manager',replace=CAT()) |
---|
71 | checkbox_lbl[0] = checkbox_inp |
---|
72 | checkbox_lbl[1] = 'Is Manager' |
---|
73 | checkbox_lbl['_class'] = "checkbox" |
---|
74 | |
---|
75 | inp_smt = frm.element('input',_type='submit',replace=TAG['button'](T('Submit'),_type='submit',_class='btn')) |
---|
76 | |
---|
77 | new_form_flds = [] |
---|
78 | frm_trs = frm.elements('tr') |
---|
79 | for tr in frm_trs: |
---|
80 | label = tr[0][0] |
---|
81 | input = tr[1][0] |
---|
82 | help = tr[2][0] |
---|
83 | new_form_flds.append(label) |
---|
84 | new_form_flds.append(input) |
---|
85 | new_form_flds.append(help) |
---|
86 | pass |
---|
87 | new_frm_content = frm.element('table',replace=CAT(*new_form_flds)) |
---|
88 | new_frm = grid.element('div.web2py_grid form',replace=lambda me:DIV(me,_class='row-fluid')) |
---|
89 | elif request.args(0)=='view': |
---|
90 | bck_btn = grid.element('div.web2py_grid span.leftarrow').parent |
---|
91 | bck_btn['_id'] = 'w2p_grid_bckbtn' |
---|
92 | bck_btn['_class'] = 'w2p_trap btn' |
---|
93 | pen_btn = grid.element('div.web2py_grid span.pen').parent |
---|
94 | pen_btn['_id'] = 'w2p_grid_penbtn' |
---|
95 | pen_btn['_class'] = 'w2p_trap btn' |
---|
96 | frm = grid.element('div.web2py_grid form') |
---|
97 | frm['_class'] = 'web2py_form span4 well well-small' |
---|
98 | |
---|
99 | checkbox_lbl = frm.element('label',_for='auth_user_is_manager') |
---|
100 | checkbox_inp = frm.element(_name='is_manager',replace=CAT()) |
---|
101 | checkbox_lbl[0] = checkbox_inp |
---|
102 | checkbox_lbl[1] = 'Is Manager' |
---|
103 | checkbox_lbl['_class'] = "checkbox" |
---|
104 | |
---|
105 | new_form_flds = [] |
---|
106 | frm_trs = frm.elements('tr') |
---|
107 | for tr in frm_trs: |
---|
108 | label = tr[0][0] |
---|
109 | input = tr[1][0] |
---|
110 | help = tr[2][0] |
---|
111 | new_form_flds.append(label) |
---|
112 | if len(input) > 0 : |
---|
113 | new_form_flds.append(SPAN(input,_class='uneditable-input')) |
---|
114 | pass |
---|
115 | new_form_flds.append(help) |
---|
116 | pass |
---|
117 | new_frm_content = frm.element('table',replace=CAT(*new_form_flds)) |
---|
118 | new_frm = grid.element('div.web2py_grid form',replace=lambda me:DIV(me,_class='row-fluid')) |
---|
119 | elif request.args(0)=='edit': |
---|
120 | bck_btn = grid.element('div.web2py_grid span.leftarrow').parent |
---|
121 | bck_btn['_id'] = 'w2p_grid_bckbtn' |
---|
122 | bck_btn['_class'] = 'w2p_trap btn' |
---|
123 | viw_btn = grid.element('div.web2py_grid span.magnifier').parent |
---|
124 | viw_btn['_id'] = 'w2p_grid_viwbtn' |
---|
125 | viw_btn['_class'] = 'w2p_trap btn' |
---|
126 | frm = grid.element('div.web2py_grid form') |
---|
127 | frm['_class'] = 'web2py_form span4 well well-small' |
---|
128 | |
---|
129 | checkbox_lbl = frm.element('label',_for='auth_user_is_manager') |
---|
130 | checkbox_inp = frm.element(_name='is_manager',replace=CAT()) |
---|
131 | checkbox_lbl[0] = checkbox_inp |
---|
132 | checkbox_lbl[1] = 'Is Manager' |
---|
133 | checkbox_lbl['_class'] = "checkbox" |
---|
134 | |
---|
135 | checkbox1_lbl = frm.element('label',_for='delete_record') |
---|
136 | checkbox1_inp = frm.element(_id='delete_record',replace=CAT()) |
---|
137 | checkbox1_lbl[0] = checkbox1_inp |
---|
138 | checkbox1_lbl[1] = T('Check to delete') |
---|
139 | checkbox1_lbl['_class'] = "checkbox" |
---|
140 | |
---|
141 | inp_smt = frm.element('input',_type='submit',replace=TAG['button'](T('Submit'),_type='submit',_class='btn')) |
---|
142 | |
---|
143 | id_input = frm.element(_id='auth_user_id') |
---|
144 | id_input['_class'] = 'uneditable-input' |
---|
145 | |
---|
146 | new_form_flds = [] |
---|
147 | frm_trs = frm.elements('tr') |
---|
148 | for tr in frm_trs: |
---|
149 | label = tr[0][0] |
---|
150 | input = tr[1][0] |
---|
151 | help = tr[2][0] |
---|
152 | new_form_flds.append(label) |
---|
153 | print(label) |
---|
154 | new_form_flds.append(input) |
---|
155 | new_form_flds.append(help) |
---|
156 | pass |
---|
157 | new_frm_content = frm.element('table',replace=CAT(*new_form_flds)) |
---|
158 | new_frm = grid.element('div.web2py_grid form',replace=lambda me:DIV(me,_class='row-fluid')) |
---|
159 | pass |
---|
160 | }} |
---|
161 | |
---|
162 | <h2>{{=T('Manage Admin Users/Students')}}</h2> |
---|
163 | {{=grid}} |
---|