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

« back to all changes in this revision

Viewing changes to lib/common/db.py

  • Committer: mattgiuca
  • Date: 2008-07-27 13:46:58 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:958
db: Added "get_subjects", which retrieves all subjects in the system.
    get_enrolment now returns URL.
subjects app: Now gets the subjects from the database and presents links based
    on the URL in the DB, rather than guessing links from the directory
    listing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
848
848
 
849
849
    # SUBJECTS AND ENROLEMENT
850
850
 
 
851
    def get_subjects(self, dry=False):
 
852
        """
 
853
        Get all subjects in IVLE.
 
854
        Returns a list of dicts (all values strings), with the keys:
 
855
        subj_code, subj_name, subj_short_name, url
 
856
        """
 
857
        return self.get_all("subject",
 
858
            ("subj_code", "subj_name", "subj_short_name", "url"), dry)
 
859
 
851
860
    def get_enrolment(self, login, dry=False):
852
861
        """
853
862
        Get all subjects (in IVLE) the student is enrolled in.
854
 
        Returns a list of tuples (all elements strings):
855
 
        (offeringid, subj_code, subj_name, subj_short_name, year, semester).
 
863
        Returns a list of dicts (all values strings), with the keys:
 
864
        offeringid, subj_code, subj_name, subj_short_name, year, semester, url
856
865
        """
857
866
        query = """\
858
867
SELECT offering.offeringid, subj_code, subj_name, subj_short_name,
859
 
       semester.year, semester.semester
 
868
       semester.year, semester.semester, subject.url
860
869
FROM login, enrolment, offering, subject, semester
861
870
WHERE enrolment.offeringid=offering.offeringid
862
871
  AND login.loginid=enrolment.loginid