##// END OF EJS Templates
admin-users: replace the previous nullslast() with db independent solution....
marcink -
r1636:917dc475 stable
parent child Browse files
Show More
@@ -19,9 +19,11 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 import datetime
22
23
23 from pyramid.httpexceptions import HTTPFound
24 from pyramid.httpexceptions import HTTPFound
24 from pyramid.view import view_config
25 from pyramid.view import view_config
26 from sqlalchemy.sql.functions import coalesce
25
27
26 from rhodecode.lib.helpers import Page
28 from rhodecode.lib.helpers import Page
27 from rhodecode_tools.lib.ext_json import json
29 from rhodecode_tools.lib.ext_json import json
@@ -125,12 +127,21 b' class AdminUsersView(BaseAppView):'
125 users_data_total_filtered_count = base_q.count()
127 users_data_total_filtered_count = base_q.count()
126
128
127 sort_col = getattr(User, order_by, None)
129 sort_col = getattr(User, order_by, None)
128 if sort_col and order_dir == 'asc':
130 if sort_col:
129 base_q = base_q.order_by(sort_col.asc())
131 if order_dir == 'asc':
130 elif sort_col:
132 # handle null values properly to order by NULL last
131 base_q = base_q.order_by(sort_col.desc())
133 if order_by in ['last_activity']:
134 sort_col = coalesce(sort_col, datetime.date.max)
135 sort_col = sort_col.asc()
136 else:
137 # handle null values properly to order by NULL last
138 if order_by in ['last_activity']:
139 sort_col = coalesce(sort_col, datetime.date.min)
140 sort_col = sort_col.desc()
132
141
142 base_q = base_q.order_by(sort_col)
133 base_q = base_q.offset(start).limit(limit)
143 base_q = base_q.offset(start).limit(limit)
144
134 users_list = base_q.all()
145 users_list = base_q.all()
135
146
136 users_data = []
147 users_data = []
General Comments 0
You need to be logged in to leave comments. Login now