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

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/subject.py

  • Committer: Matt Giuca
  • Date: 2010-02-25 07:54:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1731.
  • Revision ID: matt.giuca@gmail.com-20100225075447-1w0kzckk4xhr7p9q
Added project delete view, and ability to delete projects in the database. Currently unlinked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
856
856
        req.store.add(new_project)
857
857
        return new_project
858
858
 
 
859
class ProjectDelete(XHTMLView):
 
860
    """A form to delete a project."""
 
861
    template = 'templates/project-delete.html'
 
862
    tab = 'subjects'
 
863
    permission = 'edit'
 
864
 
 
865
    def populate(self, req, ctx):
 
866
        # If post, delete the project, or display a message explaining that
 
867
        # the project cannot be deleted
 
868
        if self.context.can_delete:
 
869
            if req.method == 'POST':
 
870
                self.context.delete()
 
871
                self.template = 'templates/project-deleted.html'
 
872
        else:
 
873
            # Can't delete
 
874
            self.template = 'templates/project-undeletable.html'
 
875
 
 
876
        # If get and can delete, display a delete confirmation page
 
877
 
 
878
        # Variables for the template
 
879
        ctx['req'] = req
 
880
        ctx['project'] = self.context
 
881
        ctx['OfferingProjectsView'] = OfferingProjectsView
 
882
 
859
883
class ProjectSetSchema(formencode.Schema):
860
884
    group_size = formencode.validators.Int(if_missing=None, not_empty=False)
861
885
 
935
959
             (ProjectSet, '+new', ProjectNew),
936
960
             (Project, '+index', ProjectView),
937
961
             (Project, '+edit', ProjectEdit),
 
962
             (Project, '+delete', ProjectDelete),
938
963
             ]
939
964
 
940
965
    breadcrumbs = {Subject: SubjectBreadcrumb,