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

1165.3.2 by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to
1
import ivle.database
2
from ivle.database import ProjectSet, Subject, Semester, Offering
3
4
from ivle.webapp.admin.projectservice import ProjectSetRESTView
5
from ivle.webapp.groups import GroupsView
1358 by William Grant
Use the publishing framework to generate URLs to projectsets.
6
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation,
1360 by William Grant
Fix missing GroupsView when creating a project set.
7
                                   require_permission)
1165.3.2 by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to
8
from ivle.webapp.errors import NotFound
9
10
class OfferingRESTView(XHTMLRESTView):
11
    """REST view for a subject.
12
      
13
    This view allows for added a ProjectSet to an existing subject."""
14
15
    template = "subject.html"
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
1165.4.1 by Nick Chadwick
Modified offeringservice to correctly add in a Solo Project.
23
        else:
24
            new_projectset.max_students_per_group = int(group_size)
25
        new_projectset.offering = self.context
26
1165.3.2 by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to
27
        req.store.add(new_projectset)
28
        req.store.flush()
29
30
        self.ctx['req'] = req
31
        self.ctx['projectset'] = new_projectset
1358 by William Grant
Use the publishing framework to generate URLs to projectsets.
32
        self.ctx['projects'] = []
1165.3.30 by William Grant
Clean out the projectset fragment context.
33
        self.ctx['GroupsView'] = GroupsView
1165.3.2 by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to
34
        self.ctx['ProjectSetRESTView'] = ProjectSetRESTView
1360 by William Grant
Fix missing GroupsView when creating a project set.
35
1358 by William Grant
Use the publishing framework to generate URLs to projectsets.
36
        self.template = 'templates/projectset_fragment.html'
1165.3.2 by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to
37
38
        return {'success': True, 'projectset_id': new_projectset.id}
39
40