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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-03-03 01:48:48 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090303014848-dyurvmtmbneohd7f
Modified the setup script to include '.txt' files.

This allows the automatic inclusion of definitions.txt from the rst
code, as it is needed by all worksheets.

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.base.rest import (XHTMLRESTView, named_operation,
7
 
                                   require_permission)
8
 
 
9
 
from ivle.webapp.errors import NotFound
10
 
 
11
 
class OfferingRESTView(XHTMLRESTView):
12
 
    """REST view for a subject.
13
 
      
14
 
    This view allows for added a ProjectSet to an existing subject."""
15
 
 
16
 
    template = "subject.html"
17
 
 
18
 
    def new_project_url(self, projectset):
19
 
        return "/api/subjects/" + str(self.context.subject.id) + "/" +\
20
 
               self.context.semester.year + "/" +\
21
 
               self.context.semester.semester + "/+projectsets/" +\
22
 
               (str(projectset.id)) + "/+projects/+new"
23
 
 
24
 
    @named_operation('edit')
25
 
    def add_projectset(self, req, group_size):
26
 
        """Add a new ProjectSet"""
27
 
        new_projectset = ProjectSet()
28
 
        if group_size == '':
29
 
            new_projectset.max_students_per_group = None
30
 
        else:
31
 
            new_projectset.max_students_per_group = int(group_size)
32
 
        new_projectset.offering = self.context
33
 
 
34
 
        req.store.add(new_projectset)
35
 
        req.store.flush()
36
 
 
37
 
        self.ctx['projectset'] = new_projectset
38
 
        self.ctx['projects'] = []
39
 
        self.ctx['new_project_url'] = self.new_project_url(new_projectset)
40
 
 
41
 
        self.template = 'templates/projectset_fragment.html'
42
 
 
43
 
        return {'success': True, 'projectset_id': new_projectset.id}