~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: 2010-07-27 12:09:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1826.
  • Revision ID: grantw@unimelb.edu.au-20100727120913-v0kfnwxzbiwrjnue
(simple)json always returns a unicode when decoding, while cjson returned a str where possible. This makes cPickle unhappy, so convert back to a str.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
3
 
import ivle.database
4
 
from ivle.database import ProjectSet, Subject, Semester, Offering
5
 
 
6
 
from ivle.webapp.admin.projectservice import ProjectSetRESTView
7
 
from ivle.webapp.groups import GroupsView
8
 
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation,
9
 
                                   require_permission)
10
 
from ivle.webapp.errors import NotFound
11
 
 
12
 
class OfferingRESTView(XHTMLRESTView):
13
 
    """REST view for a subject.
14
 
      
15
 
    This view allows for added a ProjectSet to an existing subject."""
16
 
 
17
 
    @named_operation('edit')
18
 
    def add_projectset(self, req, group_size):
19
 
        """Add a new ProjectSet"""
20
 
        new_projectset = ProjectSet()
21
 
        if group_size == '':
22
 
            new_projectset.max_students_per_group = None
23
 
        else:
24
 
            new_projectset.max_students_per_group = int(group_size)
25
 
        new_projectset.offering = self.context
26
 
 
27
 
        req.store.add(new_projectset)
28
 
        req.store.flush()
29
 
 
30
 
        self.ctx['req'] = req
31
 
        self.ctx['projectset'] = new_projectset
32
 
        self.ctx['projects'] = []
33
 
        self.ctx['GroupsView'] = GroupsView
34
 
        self.ctx['ProjectSetRESTView'] = ProjectSetRESTView
35
 
 
36
 
        self.template = 'templates/projectset_fragment.html'
37
 
 
38
 
        return {'success': True, 'projectset_id': new_projectset.id}