~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:32:05 UTC
  • mto: (1165.3.1 submissions)
  • mto: This revision was merged to the branch mainline in revision 1174.
  • Revision ID: grantw@unimelb.edu.au-20090326073205-b9pl5dz5brf0w3r7
Implement ProjectGroup.get_projects(), with identical interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
430
430
        return "<%s %s in %r>" % (type(self).__name__, self.name,
431
431
                                  self.project_set.offering)
432
432
 
 
433
    def get_projects(self, offering=None, active_only=True):
 
434
        '''Return Projects that the group can submit.
 
435
 
 
436
        This will include projects in the project set which owns this group,
 
437
        unless the project set disallows groups (in which case none will be
 
438
        returned).
 
439
 
 
440
        Unless active_only is False, projects will only be returned if the
 
441
        group's offering is active.
 
442
 
 
443
        If an offering is specified, projects will only be returned if it
 
444
        matches the group's.
 
445
        '''
 
446
        return Store.of(self).find(Project,
 
447
            Project.project_set_id == ProjectSet.id,
 
448
            ProjectSet.id == self.project_set.id,
 
449
            ProjectSet.max_students_per_group > 0,
 
450
            ProjectSet.offering_id == Offering.id,
 
451
            (offering is None) or (Offering.id == offering.id),
 
452
            Semester.id == Offering.semester_id,
 
453
            (not active_only) or (Semester.state == u'current'))
 
454
 
 
455
 
433
456
    def get_permissions(self, user):
434
457
        if user.admin or user in self.members:
435
458
            return set(['submit_project'])