~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-19 03:34:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: grantw@unimelb.edu.au-20090119033445-159eansaqt1qhaj8
ivle.db: Remove get_groups_by_user. It's unused.

Show diffs side-by-side

added added

removed removed

Lines of Context:
924
924
            return query
925
925
        return self.db.query(query).dictresult()
926
926
 
927
 
 
928
 
    # PROJECT GROUPS
929
 
    def get_groups_by_user(self, login, offeringid=None, dry=False):
930
 
        """
931
 
        Get all project groups the student is in, corresponding to a
932
 
        particular subject offering (or all offerings, if omitted).
933
 
        Returns a list of tuples:
934
 
        (int groupid, str groupnm, str group_nick, bool is_member).
935
 
        (Note: If is_member is false, it means they have just been invited to
936
 
        this group, not a member).
937
 
        """
938
 
        if offeringid is None:
939
 
            and_offering = ""
940
 
        else:
941
 
            and_projectset_table = ", project_set"
942
 
            and_offering = """
943
 
AND project_group.projectsetid = project_set.projectsetid
944
 
AND project_set.offeringid = %s""" % _escape(offeringid)
945
 
        # Union both the groups this user is a member of, and the groups this
946
 
        # user is invited to.
947
 
        query = """\
948
 
    SELECT project_group.groupid, groupnm, project_group.nick, True
949
 
    FROM project_group, group_member, login %(and_projectset_table)s
950
 
    WHERE project_group.groupid = group_member.groupid
951
 
      AND group_member.loginid = login.loginid
952
 
      AND login = %(login)s
953
 
      %(and_offering)s
954
 
UNION
955
 
    SELECT project_group.groupid, groupnm, project_group.nick, False
956
 
    FROM project_group, group_invitation, login %(and_projectset_table)s
957
 
    WHERE project_group.groupid = group_invitation.groupid
958
 
      AND group_invitation.loginid = login.loginid
959
 
      AND login = %(login)s
960
 
      %(and_offering)s
961
 
;""" % {"login": _escape(login), "and_offering": and_offering,
962
 
        "and_projectset_table": and_projectset_table}
963
 
        if dry:
964
 
            return query
965
 
        # Convert 't' -> True, 'f' -> False
966
 
        return [(groupid, groupnm, nick, ismember == 't')
967
 
                for groupid, groupnm, nick, ismember
968
 
                in self.db.query(query).getresult()]
969
 
 
970
927
    def get_offering_info(self, projectsetid, dry=False):
971
928
        """Takes information from projectset and returns useful information 
972
929
        about the subject and semester. Returns as a dictionary.