~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-24 02:32:25 UTC
  • mto: This revision was merged to the branch mainline in revision 1682.
  • Revision ID: matt.giuca@gmail.com-20100224023225-v865wseuuo3ge0fb
Added new offering SubjectOfferingNew (+new-offering under a subject name). This is identical to +new-offering, but it is locked to a particular subject. The 'Create new offering' button on the subject page now links to this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
279
279
        ctx['offerings'] = list(self.context.offerings)
280
280
        ctx['permissions'] = self.context.get_permissions(req.user,req.config)
281
281
        ctx['SubjectEdit'] = SubjectEdit
 
282
        ctx['SubjectOfferingNew'] = SubjectOfferingNew
282
283
 
283
284
 
284
285
class OfferingView(XHTMLView):
411
412
        ctx['subjects'] = req.store.find(Subject).order_by(Subject.name)
412
413
        ctx['semesters'] = req.store.find(Semester).order_by(
413
414
            Semester.year, Semester.semester)
 
415
        ctx['force_subject'] = None
414
416
 
415
417
    def populate_state(self, state):
416
418
        state.existing_offering = self.context
450
452
        ctx['subjects'] = req.store.find(Subject).order_by(Subject.name)
451
453
        ctx['semesters'] = req.store.find(Semester).order_by(
452
454
            Semester.year, Semester.semester)
 
455
        ctx['force_subject'] = None
453
456
 
454
457
    def populate_state(self, state):
455
458
        state.existing_offering = None
467
470
        req.store.add(new_offering)
468
471
        return new_offering
469
472
 
 
473
class SubjectOfferingNew(OfferingNew):
 
474
    """A form to create an offering for a given subject."""
 
475
    # Identical to OfferingNew, except it forces the subject to be the subject
 
476
    # in context
 
477
    def populate(self, req, ctx):
 
478
        super(SubjectOfferingNew, self).populate(req, ctx)
 
479
        ctx['force_subject'] = self.context
470
480
 
471
481
class OfferingCloneWorksheetsSchema(formencode.Schema):
472
482
    subject = formencode.All(
756
766
             (ApplicationRoot, ('+semesters', '+new'), SemesterNew),
757
767
             (Subject, '+index', SubjectView),
758
768
             (Subject, '+edit', SubjectEdit),
 
769
             (Subject, '+new-offering', SubjectOfferingNew),
759
770
             (Semester, '+edit', SemesterEdit),
760
771
             (Offering, '+index', OfferingView),
761
772
             (Offering, '+edit', OfferingEdit),