Hotfix FAS2
This hotfix brings a few features - Limit the user returned to a specified status (allowing to retrieve only the active accounts) - Search user by their email address - Search user by their IRC nick - Does not perform a LIKE query if there is no '%' in the pattern searched
This commit is contained in:
parent
25efc74423
commit
0755239efd
1 changed files with 32 additions and 3 deletions
|
@ -603,13 +603,19 @@ If this is not expected, please contact admin@fedoraproject.org and let them kno
|
|||
#@validate(validators=UserList())
|
||||
@identity.require(identity.not_anonymous())
|
||||
@expose(template="fas.templates.user.list", allow_json=True)
|
||||
def list(self, search=u'a*', fields=None, limit=None):
|
||||
def list(self, search=u'a*', fields=None, limit=None, status=None,
|
||||
by_email=None, by_ircnick=None):
|
||||
'''List users
|
||||
|
||||
:kwarg search: Limit the users returned by the search string. * is a
|
||||
wildcard character.
|
||||
:kwarg fields: Fields to return in the json request. Default is
|
||||
to return everything.
|
||||
:kwargs status: if specified, only returns accounts with this status.
|
||||
:kwargs by_email: if true or 1, the search is done by email instead of
|
||||
nickname.
|
||||
:kwargs by_ircnick: if true or 1, the search is done by ircnick instead
|
||||
of nickname.
|
||||
|
||||
This should be fixed up at some point. Json data needs at least the
|
||||
following for fasClient to work::
|
||||
|
@ -668,8 +674,31 @@ If this is not expected, please contact admin@fedoraproject.org and let them kno
|
|||
onclause=PersonRolesTable.c.person_id==PeopleTable.c.id)\
|
||||
.outerjoin(GroupsTable,
|
||||
onclause=PersonRolesTable.c.group_id==GroupsTable.c.id)
|
||||
stmt = select([joined_roles]).where(People.username.ilike(re_search))\
|
||||
.order_by(People.username).limit(limit)
|
||||
|
||||
if str(by_email).lower() in ['1', 'true']:
|
||||
if ur'%' in re_search:
|
||||
stmt = select([joined_roles]).where(People.email.ilike(
|
||||
re_search)).order_by(People.username).limit(limit)
|
||||
else:
|
||||
stmt = select([joined_roles]).where(People.email==re_search)\
|
||||
.order_by(People.username).limit(limit)
|
||||
elif str(by_ircnick).lower() in ['1', 'true']:
|
||||
if ur'%' in re_search:
|
||||
stmt = select([joined_roles]).where(People.ircnick.ilike(
|
||||
re_search)).order_by(People.username).limit(limit)
|
||||
else:
|
||||
stmt = select([joined_roles]).where(People.ircnick==re_search)\
|
||||
.order_by(People.username).limit(limit)
|
||||
else:
|
||||
if ur'%' in re_search:
|
||||
stmt = select([joined_roles]).where(People.username.ilike(
|
||||
re_search)).order_by(People.username).limit(limit)
|
||||
else:
|
||||
stmt = select([joined_roles]).where(People.username==re_search)\
|
||||
.order_by(People.username).limit(limit)
|
||||
|
||||
if status is not None:
|
||||
stmt = stmt.where(People.status==status)
|
||||
stmt.use_labels = True
|
||||
people = stmt.execute()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue