diff options
| author | Pierre-Yves Chibon <pingou@pingoured.fr> | 2016-06-13 10:28:04 +0200 |
|---|---|---|
| committer | Pierre-Yves Chibon <pingou@pingoured.fr> | 2016-06-13 10:30:05 +0200 |
| commit | 0755239efd69c2aa2d30082a32a5037a92e69dfe (patch) | |
| tree | 683ac39ec54bd82551bb4af8adcf0e49ac0ed396 /roles/fas_server/files | |
| parent | 25efc74423fb1edfafb7c3a025a65b43235332d8 (diff) | |
| download | ansible-0755239efd69c2aa2d30082a32a5037a92e69dfe.tar.gz ansible-0755239efd69c2aa2d30082a32a5037a92e69dfe.tar.xz ansible-0755239efd69c2aa2d30082a32a5037a92e69dfe.zip | |
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
Diffstat (limited to 'roles/fas_server/files')
| -rw-r--r-- | roles/fas_server/files/user.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/roles/fas_server/files/user.py b/roles/fas_server/files/user.py index 0f246da3f..39ee443d2 100644 --- a/roles/fas_server/files/user.py +++ b/roles/fas_server/files/user.py @@ -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() |
