server/users: sort by name by default
This commit is contained in:
parent
543d0fca57
commit
0b5f436f40
|
@ -46,6 +46,7 @@ class SearchExecutor(object):
|
||||||
query = self._handle_anonymous(
|
query = self._handle_anonymous(
|
||||||
query, self._create_criterion(token, negated))
|
query, self._create_criterion(token, negated))
|
||||||
|
|
||||||
|
query = self._search_config.finalize_query(query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def _handle_key_value(self, query, key, value, negated):
|
def _handle_key_value(self, query, key, value, negated):
|
||||||
|
|
|
@ -8,6 +8,9 @@ class UserSearchConfig(BaseSearchConfig):
|
||||||
def create_query(self, session):
|
def create_query(self, session):
|
||||||
return session.query(db.User)
|
return session.query(db.User)
|
||||||
|
|
||||||
|
def finalize_query(self, query):
|
||||||
|
return query.order_by(db.User.name.asc())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def anonymous_filter(self):
|
def anonymous_filter(self):
|
||||||
return self._create_basic_filter(db.User.name, allow_ranged=False)
|
return self._create_basic_filter(db.User.name, allow_ranged=False)
|
||||||
|
|
|
@ -124,8 +124,9 @@ class TestUserSearchExecutor(DatabaseTestCase):
|
||||||
self._test('', 2, 1, 2, ['u2'])
|
self._test('', 2, 1, 2, ['u2'])
|
||||||
|
|
||||||
def test_order_by_name(self):
|
def test_order_by_name(self):
|
||||||
self.session.add(util.mock_user('u1'))
|
|
||||||
self.session.add(util.mock_user('u2'))
|
self.session.add(util.mock_user('u2'))
|
||||||
|
self.session.add(util.mock_user('u1'))
|
||||||
|
self._test('', 1, 100, 2, ['u1', 'u2'])
|
||||||
self._test('order:name', 1, 100, 2, ['u1', 'u2'])
|
self._test('order:name', 1, 100, 2, ['u1', 'u2'])
|
||||||
self._test('-order:name', 1, 100, 2, ['u2', 'u1'])
|
self._test('-order:name', 1, 100, 2, ['u2', 'u1'])
|
||||||
self._test('order:name,asc', 1, 100, 2, ['u1', 'u2'])
|
self._test('order:name,asc', 1, 100, 2, ['u1', 'u2'])
|
||||||
|
|
Loading…
Reference in New Issue