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

« back to all changes in this revision

Viewing changes to ivle/database.py

  • Committer: William Grant
  • Date: 2009-03-26 07:22:04 UTC
  • mto: (1165.3.1 submissions)
  • mto: This revision was merged to the branch mainline in revision 1174.
  • Revision ID: grantw@unimelb.edu.au-20090326072204-rezo907h333ynu7c
Let callsites ask User.get_projects() to show inactive offerings too.

While we're there, make the offering restriction work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
        '''A sanely ordered list of all of the user's enrolments.'''
186
186
        return self._get_enrolments(False) 
187
187
 
188
 
    def get_projects(self, offering=None):
 
188
    def get_projects(self, offering=None, active_only=True):
189
189
        '''Return Projects that the user can submit.
190
190
 
191
 
        This will include projects for active offerings in which the user is
 
191
        This will include projects for offerings in which the user is
192
192
        enrolled, as long as the project is not in a project set which has
193
193
        groups (ie. if maximum number of group members is 0).
194
194
 
 
195
        Unless active_only is False, only projects for active offerings will
 
196
        be returned.
 
197
 
195
198
        If an offering is specified, returned projects will be limited to
196
199
        those for that offering.
197
200
        '''
199
202
            Project.project_set_id == ProjectSet.id,
200
203
            ProjectSet.max_students_per_group == 0,
201
204
            ProjectSet.offering_id == Offering.id,
 
205
            (offering is None) or (Offering.id == offering.id),
202
206
            Semester.id == Offering.semester_id,
203
 
            Semester.state == u'current',
 
207
            (not active_only) or (Semester.state == u'current'),
204
208
            Enrolment.offering_id == Offering.id,
205
209
            Enrolment.user_id == self.id)
206
210