4
from ivle.database import ProjectSet, Subject, Semester, Offering
6
from ivle.webapp.admin.projectservice import ProjectSetRESTView
7
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation,
9
from ivle.webapp.errors import NotFound
11
class OfferingRESTView(XHTMLRESTView):
12
"""REST view for a subject.
14
This view allows for added a ProjectSet to an existing subject."""
16
template = "subject.html"
18
@named_operation('edit')
19
def add_projectset(self, req, group_size):
20
"""Add a new ProjectSet"""
21
new_projectset = ProjectSet()
23
new_projectset.max_students_per_group = None
25
new_projectset.max_students_per_group = int(group_size)
26
new_projectset.offering = self.context
28
req.store.add(new_projectset)
32
self.ctx['projectset'] = new_projectset
33
self.ctx['projects'] = []
34
self.ctx['ProjectSetRESTView'] = ProjectSetRESTView
36
self.template = 'templates/projectset_fragment.html'
38
return {'success': True, 'projectset_id': new_projectset.id}