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

« back to all changes in this revision

Viewing changes to lib/common/db.py

  • Committer: dcoles
  • Date: 2008-08-09 08:05:13 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1001
Groups: Added the view half of the group admin panel. This lets people with the 
MANAGEGROUPS capibility to see all the project sets and groups in each subject 
offering for that subject. Next is to use the new userservice calls to add and 
modify these groups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
888
888
        subj_code, subj_name, subj_short_name, url
889
889
        """
890
890
        return self.get_all("subject",
891
 
            ("subj_code", "subj_name", "subj_short_name", "url"), dry)
 
891
            ("subjectid", "subj_code", "subj_name", "subj_short_name", "url"),
 
892
            dry)
 
893
 
 
894
    def get_offering_semesters(self, subjectid, dry=False):
 
895
        """
 
896
        Get the semester information for a subject as well as providing 
 
897
        information about if the subject is active and which semester it is in.
 
898
        """
 
899
        query = """\
 
900
SELECT offeringid, subj_name, year, semester, active
 
901
FROM semester, offering, subject
 
902
WHERE offering.semesterid = semester.semesterid AND
 
903
    offering.subject = subject.subjectid AND
 
904
    offering.subject = %d;"""%subjectid
 
905
        if dry:
 
906
            return query
 
907
        results = self.db.query(query).dictresult()
 
908
        # Parse boolean varibles
 
909
        for result in results:
 
910
            result['active'] = _parse_boolean(result['active'])
 
911
        return results
892
912
 
893
913
    def get_enrolment(self, login, dry=False):
894
914
        """
952
972
 
953
973
 
954
974
    # PROJECT GROUPS
955
 
 
956
975
    def get_groups_by_user(self, login, offeringid=None, dry=False):
957
976
        """
958
977
        Get all project groups the student is in, corresponding to a
1022
1041
            return query
1023
1042
        return self.db.query(query).dictresult()
1024
1043
 
 
1044
    def get_projectsets_by_offering(self, offeringid, dry=False):
 
1045
        """Returns all the projectsets in a particular offering"""
 
1046
        query = """\
 
1047
SELECT projectsetid, max_students_per_group
 
1048
FROM project_set
 
1049
WHERE project_set.offeringid = %d;"""%offeringid
 
1050
        if dry:
 
1051
            return query
 
1052
        return self.db.query(query).dictresult()
 
1053
 
 
1054
    def get_groups_by_projectset(self, projectsetid, dry=False):
 
1055
        """Returns all the groups that are in a particular projectset"""
 
1056
        query = """\
 
1057
SELECT groupid, groupnm, nick, createdby, epoch
 
1058
FROM project_group
 
1059
WHERE project_group.projectsetid = %d;"""%projectsetid
 
1060
        if dry:
 
1061
            return query
 
1062
        return self.db.query(query).dictresult()
 
1063
 
1025
1064
    def close(self):
1026
1065
        """Close the DB connection. Do not call any other functions after
1027
1066
        this. (The behaviour of doing so is undefined).