Show More
@@ -130,6 +130,34 b' class RepoAppView(BaseAppView):' | |||||
130 | return c |
|
130 | return c | |
131 |
|
131 | |||
132 |
|
132 | |||
|
133 | class DataGridAppView(object): | |||
|
134 | """ | |||
|
135 | Common class to have re-usable grid rendering components | |||
|
136 | """ | |||
|
137 | ||||
|
138 | def _extract_ordering(self, request): | |||
|
139 | column_index = safe_int(request.GET.get('order[0][column]')) | |||
|
140 | order_dir = request.GET.get( | |||
|
141 | 'order[0][dir]', 'desc') | |||
|
142 | order_by = request.GET.get( | |||
|
143 | 'columns[%s][data][sort]' % column_index, 'name_raw') | |||
|
144 | ||||
|
145 | # translate datatable to DB columns | |||
|
146 | order_by = { | |||
|
147 | 'first_name': 'name', | |||
|
148 | 'last_name': 'lastname', | |||
|
149 | }.get(order_by) or order_by | |||
|
150 | ||||
|
151 | search_q = request.GET.get('search[value]') | |||
|
152 | return search_q, order_by, order_dir | |||
|
153 | ||||
|
154 | def _extract_chunk(self, request): | |||
|
155 | start = safe_int(request.GET.get('start'), 0) | |||
|
156 | length = safe_int(request.GET.get('length'), 25) | |||
|
157 | draw = safe_int(request.GET.get('draw')) | |||
|
158 | return draw, start, length | |||
|
159 | ||||
|
160 | ||||
133 | class RepoRoutePredicate(object): |
|
161 | class RepoRoutePredicate(object): | |
134 | def __init__(self, val, config): |
|
162 | def __init__(self, val, config): | |
135 | self.val = val |
|
163 | self.val = val |
@@ -28,7 +28,7 b' from sqlalchemy.sql.functions import coa' | |||||
28 | from rhodecode.lib.helpers import Page |
|
28 | from rhodecode.lib.helpers import Page | |
29 | from rhodecode_tools.lib.ext_json import json |
|
29 | from rhodecode_tools.lib.ext_json import json | |
30 |
|
30 | |||
31 | from rhodecode.apps._base import BaseAppView |
|
31 | from rhodecode.apps._base import BaseAppView, DataGridAppView | |
32 | from rhodecode.lib.auth import ( |
|
32 | from rhodecode.lib.auth import ( | |
33 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) |
|
33 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |
34 | from rhodecode.lib import helpers as h |
|
34 | from rhodecode.lib import helpers as h | |
@@ -43,7 +43,7 b' from rhodecode.model.meta import Session' | |||||
43 | log = logging.getLogger(__name__) |
|
43 | log = logging.getLogger(__name__) | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | class AdminUsersView(BaseAppView): |
|
46 | class AdminUsersViewData(BaseAppView, DataGridAppView): | |
47 | ALLOW_SCOPED_TOKENS = False |
|
47 | ALLOW_SCOPED_TOKENS = False | |
48 | """ |
|
48 | """ | |
49 | This view has alternative version inside EE, if modified please take a look |
|
49 | This view has alternative version inside EE, if modified please take a look | |
@@ -64,28 +64,6 b' class AdminUsersView(BaseAppView):' | |||||
64 | # is a pyramid view |
|
64 | # is a pyramid view | |
65 | raise HTTPFound('/') |
|
65 | raise HTTPFound('/') | |
66 |
|
66 | |||
67 | def _extract_ordering(self, request): |
|
|||
68 | column_index = safe_int(request.GET.get('order[0][column]')) |
|
|||
69 | order_dir = request.GET.get( |
|
|||
70 | 'order[0][dir]', 'desc') |
|
|||
71 | order_by = request.GET.get( |
|
|||
72 | 'columns[%s][data][sort]' % column_index, 'name_raw') |
|
|||
73 |
|
||||
74 | # translate datatable to DB columns |
|
|||
75 | order_by = { |
|
|||
76 | 'first_name': 'name', |
|
|||
77 | 'last_name': 'lastname', |
|
|||
78 | }.get(order_by) or order_by |
|
|||
79 |
|
||||
80 | search_q = request.GET.get('search[value]') |
|
|||
81 | return search_q, order_by, order_dir |
|
|||
82 |
|
||||
83 | def _extract_chunk(self, request): |
|
|||
84 | start = safe_int(request.GET.get('start'), 0) |
|
|||
85 | length = safe_int(request.GET.get('length'), 25) |
|
|||
86 | draw = safe_int(request.GET.get('draw')) |
|
|||
87 | return draw, start, length |
|
|||
88 |
|
||||
89 | @HasPermissionAllDecorator('hg.admin') |
|
67 | @HasPermissionAllDecorator('hg.admin') | |
90 | @view_config( |
|
68 | @view_config( | |
91 | route_name='users', request_method='GET', |
|
69 | route_name='users', request_method='GET', |
General Comments 0
You need to be logged in to leave comments.
Login now