~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 12:07:23 UTC
  • mto: (1165.3.1 submissions)
  • mto: This revision was merged to the branch mainline in revision 1174.
  • Revision ID: grantw@unimelb.edu.au-20090326120723-kp8ntfcqfj0t9xq5
Add Project.submit(), to create a submission for the principal, path and rev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
407
407
        return "<%s '%s' in %r>" % (type(self).__name__, self.short_name,
408
408
                                  self.project_set.offering)
409
409
 
 
410
    def can_submit(self, principal):
 
411
        return (self in principal.get_projects() and
 
412
                self.deadline > datetime.datetime.now())
 
413
 
 
414
    def submit(self, principal, path, revision):
 
415
        if not self.can_submit(principal):
 
416
            raise Exception('cannot submit')
 
417
 
 
418
        a = Assessed.get(Store.of(self), principal, self)
 
419
        ps = ProjectSubmission()
 
420
        ps.path = path
 
421
        ps.revision = revision
 
422
        ps.date_submitted = datetime.datetime.now()
 
423
        ps.assessed = a
 
424
 
 
425
        return ps
 
426
 
 
427
 
410
428
class ProjectGroup(Storm):
411
429
    __storm_table__ = "project_group"
412
430