Skip to content

Commit

Permalink
[#1330] Get user ids from a list of ids or names
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel Babu committed Jan 27, 2014
1 parent 4fa7b5c commit 0f63dcc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ckan/model/user.py
Expand Up @@ -243,6 +243,14 @@ def search(cls, querystr, sqlalchemy_query=None, user_name=None):
query = query.filter(or_(*filters))
return query

@classmethod
def user_ids_for_name_or_id(self, user_list=[]):
query = meta.Session.query(self.id)
query = query.filter(or_(self.name.in_(user_list),
self.id.in_(user_list)))
return [user.id for user in query.all()]


meta.mapper(User, user_table,
properties={'password': synonym('_password', map_column=True)},
order_by=user_table.c.name)

0 comments on commit 0f63dcc

Please sign in to comment.