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

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/exercise_service.py

  • Committer: William Grant
  • Date: 2010-07-03 11:15:42 UTC
  • mfrom: (1796.1.3 get-named-operations)
  • Revision ID: grantw@unimelb.edu.au-20100703111542-pc9odlk2bv4tj3rr
Named operations must now be declared as read_operation or write_operation. Read operations may be executed with a GET.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from ivle.database import Exercise, TestSuite, TestCase, \
23
23
                          TestSuiteVar, TestCasePart
24
24
from ivle.webapp.base.forms import VALID_URL_NAME
25
 
from ivle.webapp.base.rest import (JSONRESTView, named_operation,
 
25
from ivle.webapp.base.rest import (JSONRESTView, write_operation,
26
26
                                   require_permission)
27
27
from ivle.webapp.errors import NotFound, BadRequest
28
28
from ivle.webapp.tutorial.test.TestFramework import (
46
46
        else:
47
47
            return set()
48
48
    
49
 
    @named_operation('save')
 
49
    @write_operation('save')
50
50
    def add_exercise(self, req, identifier, name, description, partial, solution, include, num_rows):
51
51
        if not VALID_URL_NAME.match(identifier):
52
52
            raise BadRequest(
75
75
class ExerciseRESTView(JSONRESTView):
76
76
    """View for updating Exercises"""
77
77
    
78
 
    @named_operation(u'edit')
 
78
    @write_operation(u'edit')
79
79
    def edit_exercise(self, req, name, description, partial, 
80
80
                      solution, include, num_rows):
81
81
        
87
87
        self.context.num_rows = int(num_rows)
88
88
        return {'result': 'ok'}
89
89
    
90
 
    @named_operation(u'edit')
 
90
    @write_operation(u'edit')
91
91
    def delete_exercise(self, req, id):
92
92
        
93
93
        self.context.delete()
94
94
        return {'result': 'ok'}
95
95
 
96
 
    @named_operation(u'edit')
 
96
    @write_operation(u'edit')
97
97
    def add_suite(self, req, description, function, stdin):
98
98
        
99
99
        new_suite = TestSuite()
107
107
        
108
108
        return {'result': 'ok'}
109
109
        
110
 
    @named_operation(u'edit')
 
110
    @write_operation(u'edit')
111
111
    def edit_suite(self, req, suiteid, description, function, stdin):
112
112
        
113
113
        suite = req.store.find(TestSuite,
123
123
        
124
124
        return {'result': 'ok'}
125
125
    
126
 
    @named_operation(u'edit')
 
126
    @write_operation(u'edit')
127
127
    def delete_suite(self, req, suiteid):
128
128
        
129
129
        suite = req.store.find(TestSuite,
136
136
        
137
137
        return {'result': 'ok'}
138
138
      
139
 
    @named_operation(u'edit')
 
139
    @write_operation(u'edit')
140
140
    def add_var(self, req, suiteid, var_type, var_name, var_val, argno):
141
141
 
142
142
        suite = req.store.find(TestSuite,
157
157
        
158
158
        return {'result': 'ok'}
159
159
 
160
 
    @named_operation(u'edit')
 
160
    @write_operation(u'edit')
161
161
    def edit_var(self, req, suiteid, varid, var_type, var_name, var_val, argno):
162
162
        var = req.store.find(TestSuiteVar,
163
163
            TestSuiteVar.varid == int(varid),
174
174
        
175
175
        return {'result': 'ok'}
176
176
    
177
 
    @named_operation(u'edit')
 
177
    @write_operation(u'edit')
178
178
    def delete_var(self, req, suiteid, varid):
179
179
        var = req.store.find(TestSuiteVar,
180
180
            TestSuiteVar.varid == int(varid),
186
186
        
187
187
        return {'result': 'ok'}
188
188
        
189
 
    @named_operation(u'edit')
 
189
    @write_operation(u'edit')
190
190
    def add_testcase(self, req, suiteid, passmsg, failmsg):
191
191
        
192
192
        suite = req.store.find(TestSuite,
210
210
        
211
211
        return {'result': 'ok'}
212
212
    
213
 
    @named_operation(u'edit')
 
213
    @write_operation(u'edit')
214
214
    def edit_testcase(self, req, suiteid, testid, passmsg, failmsg):
215
215
        
216
216
        suite = req.store.find(TestSuite,
230
230
        
231
231
        return {'result': 'ok'}
232
232
    
233
 
    @named_operation(u'edit')
 
233
    @write_operation(u'edit')
234
234
    def delete_testcase(self, req, suiteid, testid):
235
235
        
236
236
        suite = req.store.find(TestSuite,
249
249
 
250
250
        return {'result': 'ok'}
251
251
    
252
 
    @named_operation(u'edit')
 
252
    @write_operation(u'edit')
253
253
    def edit_testpart(self, req, suiteid, testid, partid, part_type, test_type, 
254
254
                      data):
255
255
    
277
277
        
278
278
        return {'result': 'ok'}
279
279
    
280
 
    @named_operation(u'edit')
 
280
    @write_operation(u'edit')
281
281
    def add_testpart(self, req, suiteid, testid, part_type, test_type, 
282
282
                      data):
283
283
    
302
302
        
303
303
        return {'result': 'ok'}
304
304
    
305
 
    @named_operation(u'edit')
 
305
    @write_operation(u'edit')
306
306
    def delete_testpart(self, req, suiteid, testid, partid):
307
307
        suite = req.store.find(TestSuite,
308
308
            TestSuite.suiteid == int(suiteid),
326
326
        
327
327
        return {'result': 'ok'}
328
328
 
329
 
    @named_operation(u'edit')
 
329
    @write_operation(u'edit')
330
330
    def test(self, req, code):
331
331
        from ivle.worksheet.utils import test_exercise_submission
332
332
        try: