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

« back to all changes in this revision

Viewing changes to ivle/db.py

  • Committer: William Grant
  • Date: 2009-01-20 02:49:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: grantw@unimelb.edu.au-20090120024922-6eb86loc19qwcldh
ivle.database.Enrolment: Add a groups attribute, containing groups of which
    this user is a member in this offering.
www/apps/userservice: Use Storm instead of get_enrolment_groups.
ivle.db.get_enrolment_groups: Kill. Unused.

Show diffs side-by-side

added added

removed removed

Lines of Context:
433
433
            result['active'] = _parse_boolean(result['active'])
434
434
        return results
435
435
 
436
 
    def get_enrolment_groups(self, login, offeringid, dry=False):
437
 
        """
438
 
        Get all groups the user is member of in the given offering.
439
 
        Returns a list of dicts (all values strings), with the keys:
440
 
        name, nick
441
 
        """
442
 
        query = """\
443
 
SELECT project_group.groupnm as name, project_group.nick as nick
444
 
FROM project_set, project_group, group_member, login
445
 
WHERE login.login=%s
446
 
  AND project_set.offeringid=%s
447
 
  AND group_member.loginid=login.loginid
448
 
  AND project_group.groupid=group_member.groupid
449
 
  AND project_group.projectsetid=project_set.projectsetid
450
 
""" % (_escape(login), _escape(offeringid))
451
 
        if dry:
452
 
            return query
453
 
        return self.db.query(query).dictresult()
454
 
 
455
436
    def close(self):
456
437
        """Close the DB connection. Do not call any other functions after
457
438
        this. (The behaviour of doing so is undefined).