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

« back to all changes in this revision

Viewing changes to ivle/database.py

  • Committer: Matt Giuca
  • Date: 2010-02-25 08:26:04 UTC
  • mfrom: (1710.1.25 new-project-ui)
  • Revision ID: matt.giuca@gmail.com-20100225082604-0fku57vycn5cgonf
Replaced AJAX UI for project creation with a standard one. Can now edit project sets, and edit/delete projects. Also many more links to such things, due to the fact that they have their own URLs now. Fixes Launchpad bug #493942.

Show diffs side-by-side

added added

removed removed

Lines of Context:
649
649
            return
650
650
        return assessed.submissions
651
651
 
 
652
    @property
 
653
    def can_delete(self):
 
654
        """Can only delete if there are no submissions."""
 
655
        return self.submissions.count() == 0
652
656
 
 
657
    def delete(self):
 
658
        """Delete the project. Fails if can_delete is False."""
 
659
        if not self.can_delete:
 
660
            raise IntegrityError()
 
661
        for assessed in self.assesseds:
 
662
            assessed.delete()
 
663
        Store.of(self).remove(self)
653
664
 
654
665
class ProjectGroup(Storm):
655
666
    """A group of students working together on a project."""
802
813
 
803
814
        return a
804
815
 
 
816
    def delete(self):
 
817
        """Delete the assessed. Fails if there are any submissions. Deletes
 
818
        extensions."""
 
819
        if self.submissions.count() > 0:
 
820
            raise IntegrityError()
 
821
        for extension in self.extensions:
 
822
            extension.delete()
 
823
        Store.of(self).remove(self)
805
824
 
806
825
class ProjectExtension(Storm):
807
826
    """An extension granted to a user or group on a particular project.
819
838
    approver = Reference(approver_id, User.id)
820
839
    notes = Unicode()
821
840
 
 
841
    def delete(self):
 
842
        """Delete the extension."""
 
843
        Store.of(self).remove(self)
 
844
 
822
845
class SubmissionError(Exception):
823
846
    """Denotes a validation error during submission."""
824
847
    pass