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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-07-05 08:57:26 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090705085726-w5aqfe833k3s3c0u
Add a breadcrumb generator (indexes plugins on what breadcrumbs they have).

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
    template = "subject.html"
17
17
 
18
 
    def __init__(self, req, subject, year, semester):
19
 
 
20
 
        self.context = req.store.find(Offering,
21
 
                Offering.subject_id == Subject.id,
22
 
                Subject.short_name == unicode(subject),
23
 
                Offering.semester_id == Semester.id,
24
 
                Semester.year == unicode(year),
25
 
                Semester.semester == unicode(semester)).one()
26
 
 
27
 
        if self.context is None:
28
 
            raise NotFound()
29
 
 
30
18
    def new_project_url(self, projectset):
31
19
        return "/api/subjects/" + str(self.context.subject.id) + "/" +\
32
20
               self.context.semester.year + "/" +\
37
25
    def add_projectset(self, req, group_size):
38
26
        """Add a new ProjectSet"""
39
27
        new_projectset = ProjectSet()
40
 
        new_projectset.max_students_per_group = int(group_size)
 
28
        if group_size == '':
 
29
            new_projectset.max_students_per_group = None
 
30
        else:
 
31
            new_projectset.max_students_per_group = int(group_size)
41
32
        new_projectset.offering = self.context
42
33
 
43
34
        req.store.add(new_projectset)
44
35
        req.store.flush()
45
36
 
46
 
        self.ctx['group_size'] = new_projectset.max_students_per_group
47
 
        self.ctx['projectset_id'] = new_projectset.id
 
37
        self.ctx['projectset'] = new_projectset
48
38
        self.ctx['projects'] = []
49
39
        self.ctx['new_project_url'] = self.new_project_url(new_projectset)
50
40