Show More
@@ -19,9 +19,11 b'' | |||
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import logging |
|
22 | import datetime | |
|
22 | 23 | |
|
23 | 24 | from pyramid.httpexceptions import HTTPFound |
|
24 | 25 | from pyramid.view import view_config |
|
26 | from sqlalchemy.sql.functions import coalesce | |
|
25 | 27 | |
|
26 | 28 | from rhodecode.lib.helpers import Page |
|
27 | 29 | from rhodecode_tools.lib.ext_json import json |
@@ -125,12 +127,21 b' class AdminUsersView(BaseAppView):' | |||
|
125 | 127 | users_data_total_filtered_count = base_q.count() |
|
126 | 128 | |
|
127 | 129 | sort_col = getattr(User, order_by, None) |
|
128 |
if sort_col |
|
|
129 | base_q = base_q.order_by(sort_col.asc()) | |
|
130 | elif sort_col: | |
|
131 | base_q = base_q.order_by(sort_col.desc()) | |
|
130 | if sort_col: | |
|
131 | if order_dir == 'asc': | |
|
132 | # handle null values properly to order by NULL last | |
|
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 | 143 | base_q = base_q.offset(start).limit(limit) |
|
144 | ||
|
134 | 145 | users_list = base_q.all() |
|
135 | 146 | |
|
136 | 147 | users_data = [] |
General Comments 0
You need to be logged in to leave comments.
Login now