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.base.rest import (XHTMLRESTView, named_operation, |
|
5 |
require_permission) |
|
6 |
||
7 |
from ivle.webapp.errors import NotFound |
|
8 |
||
9 |
class OfferingRESTView(XHTMLRESTView): |
|
10 |
"""REST view for a subject.
|
|
11 |
|
|
12 |
This view allows for added a ProjectSet to an existing subject."""
|
|
13 |
||
14 |
template = "subject.html" |
|
15 |
||
16 |
def new_project_url(self, projectset): |
|
17 |
return "/api/subjects/%s/%s/%s/+projectsets/%d/+projects/+new" % ( |
|
18 |
self.context.subject.short_name, self.context.semester.year, |
|
1330
by William Grant
Unbreak creation of projects in a newly-created projectset. Correct the subject in the URL (was an id), and hook up JS. |
19 |
self.context.semester.semester, projectset.id) |
20 |
||
21 |
@named_operation('edit') |
|
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
22 |
def add_projectset(self, req, group_size): |
23 |
"""Add a new ProjectSet"""
|
|
24 |
new_projectset = ProjectSet() |
|
25 |
if group_size == '': |
|
26 |
new_projectset.max_students_per_group = None |
|
1165.4.1
by Nick Chadwick
Modified offeringservice to correctly add in a Solo Project. |
27 |
else: |
28 |
new_projectset.max_students_per_group = int(group_size) |
|
29 |
new_projectset.offering = self.context |
|
30 |
||
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
31 |
req.store.add(new_projectset) |
32 |
req.store.flush() |
|
33 |
||
34 |
self.ctx['projectset'] = new_projectset |
|
35 |
self.ctx['projects'] = [] |
|
1165.3.30
by William Grant
Clean out the projectset fragment context. |
36 |
self.ctx['new_project_url'] = self.new_project_url(new_projectset) |
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
37 |
|
38 |
self.template = 'templates/projectset_fragment.html' |
|
39 |
||
40 |
return {'success': True, 'projectset_id': new_projectset.id} |
|
41 |
||
42 |