~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 04:04:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1731.
  • Revision ID: matt.giuca@gmail.com-20100225040413-cqd8ljhmf1nwr6or
Added new view for adding a new project set (offering/+projects/+new-set). This replaces the AJAX UI. The 'Add a new project set' link now links to the static 'new project set' page.

Show diffs side-by-side

added added

removed removed

Lines of Context:
760
760
        ctx['project'] = self.context
761
761
        ctx['user'] = req.user
762
762
 
 
763
class ProjectSetSchema(formencode.Schema):
 
764
    group_size = formencode.validators.Int(if_missing=None, not_empty=False)
 
765
 
 
766
class ProjectSetNew(BaseFormView):
 
767
    """A form to create a new project set."""
 
768
    template = 'templates/projectset-new.html'
 
769
    tab = 'subjects'
 
770
    permission = 'edit'
 
771
    breadcrumb_text = "Projects"
 
772
 
 
773
    @property
 
774
    def validator(self):
 
775
        return ProjectSetSchema()
 
776
 
 
777
    def populate(self, req, ctx):
 
778
        super(ProjectSetNew, self).populate(req, ctx)
 
779
 
 
780
    def get_default_data(self, req):
 
781
        return {}
 
782
 
 
783
    def save_object(self, req, data):
 
784
        new_set = ProjectSet()
 
785
        new_set.offering = self.context
 
786
        new_set.max_students_per_group = data['group_size']
 
787
        req.store.add(new_set)
 
788
        return new_set
 
789
 
763
790
class Plugin(ViewPlugin, MediaPlugin):
764
791
    forward_routes = (root_to_subject, root_to_semester, subject_to_offering,
765
792
                      offering_to_project, offering_to_projectset,
785
812
             (Enrolment, '+edit', EnrolmentEdit),
786
813
             (Enrolment, '+delete', EnrolmentDelete),
787
814
             (Offering, ('+projects', '+index'), OfferingProjectsView),
 
815
             (Offering, ('+projects', '+new-set'), ProjectSetNew),
788
816
             (Project, '+index', ProjectView),
789
817
 
790
818
             (Offering, ('+projectsets', '+new'), OfferingRESTView, 'api'),