From 02556868938511e42395685dd4cd09be8e065b84 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 08 2014 14:00:56 +0000 Subject: Add method to retrieve all the users for a specific group --- diff --git a/progit/lib.py b/progit/lib.py index 75b1a2c..b78f32c 100644 --- a/progit/lib.py +++ b/progit/lib.py @@ -953,3 +953,24 @@ def get_group(session, group): ) return query.first() + + +def get_users_by_group(session, group): + ''' Return the list of users for a specified group. + + :arg session: the session with which to connect to the database. + + ''' + query = session.query( + model.User + ).filter( + model.User.id == model.ProgitUserGroup.user_id + ).filter( + model.ProgitUserGroup.group_id == model.ProgitGroup.id + ).filter( + model.ProgitGroup.group_name == group + ).order_by( + model.User.user + ) + + return query.all()