~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 06:53:54 UTC
  • mto: This revision was merged to the branch mainline in revision 1731.
  • Revision ID: matt.giuca@gmail.com-20100225065354-uj71eqi4u3o64lv0
Added project edit page (based on project new view). Currently unlinked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
786
786
    url = formencode.validators.URL(if_missing=None, not_empty=False)
787
787
    synopsis = formencode.validators.UnicodeString(not_empty=True)
788
788
 
 
789
class ProjectEdit(BaseFormView):
 
790
    """A form to edit a project."""
 
791
    template = 'templates/project-edit.html'
 
792
    tab = 'subjects'
 
793
    permission = 'edit'
 
794
 
 
795
    @property
 
796
    def validator(self):
 
797
        return ProjectSchema()
 
798
 
 
799
    def populate(self, req, ctx):
 
800
        super(ProjectEdit, self).populate(req, ctx)
 
801
        ctx['projectset'] = self.context.project_set
 
802
 
 
803
    def populate_state(self, state):
 
804
        state.offering = self.context.project_set.offering
 
805
        state.existing_project = self.context
 
806
 
 
807
    def get_default_data(self, req):
 
808
        return {
 
809
            'name':         self.context.name,
 
810
            'short_name':   self.context.short_name,
 
811
            'deadline':     self.context.deadline,
 
812
            'url':          self.context.url,
 
813
            'synopsis':     self.context.synopsis,
 
814
            }
 
815
 
 
816
    def save_object(self, req, data):
 
817
        self.context.name = data['name']
 
818
        self.context.short_name = data['short_name']
 
819
        self.context.deadline = data['deadline']
 
820
        self.context.url = unicode(data['url']) if data['url'] else None
 
821
        self.context.synopsis = data['synopsis']
 
822
        return self.context
 
823
 
789
824
class ProjectNew(BaseFormView):
790
825
    """A form to create a new project."""
791
826
    template = 'templates/project-new.html'
896
931
             (ProjectSet, '+edit', ProjectSetEdit),
897
932
             (ProjectSet, '+new', ProjectNew),
898
933
             (Project, '+index', ProjectView),
 
934
             (Project, '+edit', ProjectEdit),
899
935
             ]
900
936
 
901
937
    breadcrumbs = {Subject: SubjectBreadcrumb,