~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/db.py

  • Committer: wagrant
  • Date: 2008-08-09 04:33:07 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:995
common.db: Add get_enrolment_groups. Will return group information for
           the given user in the given offering.
userservice: Return group information with the rest of the enrolment
             data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
910
910
            return query
911
911
        return self.db.query(query).dictresult()
912
912
 
 
913
    def get_enrolment_groups(self, login, offeringid, dry=False):
 
914
        """
 
915
        Get all groups the user is member of in the given offering.
 
916
        Returns a list of dicts (all values strings), with the keys:
 
917
        name, nick
 
918
        """
 
919
        query = """\
 
920
SELECT project_group.groupnm as name, project_group.nick as nick
 
921
FROM project_set, project_group, group_member, login
 
922
WHERE login.login=%s
 
923
  AND project_set.offeringid=%s
 
924
  AND group_member.loginid=login.loginid
 
925
  AND project_group.groupid=group_member.groupid
 
926
  AND project_group.projectsetid=project_set.projectsetid
 
927
""" % (_escape(offeringid), _escape(login))
 
928
        if dry:
 
929
            return query
 
930
        return self.db.query(query).dictresult()
 
931
 
913
932
    def get_subjects_status(self, login, dry=False):
914
933
        """
915
934
        Get all subjects in IVLE, split into lists of enrolled and unenrolled