36 from soc.logic.models.user import logic as user_logic |
36 from soc.logic.models.user import logic as user_logic |
37 from soc.logic.models.grading_survey_group import logic as survey_group_logic |
37 from soc.logic.models.grading_survey_group import logic as survey_group_logic |
38 from soc.models.grading_survey_group import GradingSurveyGroup |
38 from soc.models.grading_survey_group import GradingSurveyGroup |
39 from soc.models.grading_project_survey import GradingProjectSurvey |
39 from soc.models.grading_project_survey import GradingProjectSurvey |
40 from soc.models.project_survey import ProjectSurvey |
40 from soc.models.project_survey import ProjectSurvey |
|
41 from soc.views import out_of_band |
41 from soc.views.helper import access |
42 from soc.views.helper import access |
42 from soc.views.helper import decorators |
43 from soc.views.helper import decorators |
|
44 from soc.views.helper import lists |
43 from soc.views.helper import redirects |
45 from soc.views.helper import redirects |
|
46 from soc.views.helper import responses |
44 from soc.views.models import base |
47 from soc.views.models import base |
45 from soc.views.models import program as program_view |
48 from soc.views.models import program as program_view |
46 |
49 |
47 |
50 |
48 class View(base.View): |
51 class View(base.View): |
61 rights['create'] = ['checkIsHostForProgramInScope'] |
64 rights['create'] = ['checkIsHostForProgramInScope'] |
62 rights['edit'] = ['checkIsHostForProgramInScope'] |
65 rights['edit'] = ['checkIsHostForProgramInScope'] |
63 rights['delete'] = ['checkIsDeveloper'] |
66 rights['delete'] = ['checkIsDeveloper'] |
64 rights['show'] = ['checkIsHostForProgramInScope'] |
67 rights['show'] = ['checkIsHostForProgramInScope'] |
65 rights['list'] = ['checkIsDeveloper'] |
68 rights['list'] = ['checkIsDeveloper'] |
|
69 rights['records'] = ['checkIsHostForProgramInScope'] |
66 |
70 |
67 new_params = {} |
71 new_params = {} |
68 new_params['logic'] = survey_group_logic |
72 new_params['logic'] = survey_group_logic |
69 new_params['rights'] = rights |
73 new_params['rights'] = rights |
70 new_params['name'] = "Grading Survey Group" |
74 new_params['name'] = "Grading Survey Group" |
89 |
93 |
90 new_params['edit_extra_dynaproperties'] = { |
94 new_params['edit_extra_dynaproperties'] = { |
91 'link_id': forms.CharField(widget=forms.HiddenInput), |
95 'link_id': forms.CharField(widget=forms.HiddenInput), |
92 } |
96 } |
93 |
97 |
|
98 patterns = [ |
|
99 (r'^%(url_name)s/(?P<access_type>records)/%(key_fields)s$', |
|
100 'soc.views.models.%(module_name)s.grading_records', |
|
101 'Overview of GradingRecords'), |
|
102 ] |
|
103 |
|
104 new_params['extra_django_patterns'] = patterns |
|
105 |
|
106 new_params['records_template'] = 'soc/grading_survey_group/records.html' |
|
107 new_params['records_heading_template'] = 'soc/grading_record/list/heading.html' |
|
108 new_params['records_row_template'] = 'soc/grading_record/list/row.html' |
|
109 |
94 params = dicts.merge(params, new_params) |
110 params = dicts.merge(params, new_params) |
95 |
111 |
96 super(View, self).__init__(params=params) |
112 super(View, self).__init__(params=params) |
97 |
113 |
98 @decorators.merge_params |
114 @decorators.merge_params |
202 |
218 |
203 choices = tuple(choice_list) |
219 choices = tuple(choice_list) |
204 |
220 |
205 group_form.base_fields[field].choices = choices |
221 group_form.base_fields[field].choices = choices |
206 |
222 |
|
223 @decorators.merge_params |
|
224 @decorators.check_access |
|
225 def gradingRecords(self, request, access_type, page_name=None, params=None, |
|
226 **kwargs): |
|
227 """View which shows all collected records for a given GradingSurveyGroup. |
|
228 |
|
229 For args see base.View.public(). |
|
230 """ |
|
231 |
|
232 from soc.logic import lists as lists_logic |
|
233 from soc.logic.models.grading_record import logic as record_logic |
|
234 |
|
235 survey_group_logic = params['logic'] |
|
236 |
|
237 try: |
|
238 entity = survey_group_logic.getFromKeyFieldsOr404(kwargs) |
|
239 except out_of_band.Error, error: |
|
240 return responses.errorResponse( |
|
241 error, request, template=params['error_public']) |
|
242 |
|
243 template = params['records_template'] |
|
244 |
|
245 list_params = params.copy() |
|
246 list_params['logic'] = record_logic |
|
247 list_params['list_heading'] = params['records_heading_template'] |
|
248 list_params['list_row'] = params['records_row_template'] |
|
249 # TODO(ljvderijk) proper redirect to edit a record |
|
250 list_params['list_action'] = None |
|
251 |
|
252 # get the context for this webpage |
|
253 context = responses.getUniversalContext(request) |
|
254 responses.useJavaScript(context, params['js_uses_all']) |
|
255 context['page_name'] = "%s for %s named '%s'" %( |
|
256 page_name, params['name'], entity.name) |
|
257 context['entity'] = entity |
|
258 |
|
259 fields = {'grading_survey_group': entity} |
|
260 |
|
261 # list all records with grading_decision set to pass |
|
262 fields['grade_decision'] = 'pass' |
|
263 |
|
264 # get the list content for passing records |
|
265 pr_params = list_params.copy() |
|
266 pr_params['list_description'] = \ |
|
267 'List of all Records which have their grading outcome set to pass.' |
|
268 pr_list = lists.getListContent( |
|
269 request, pr_params, fields, idx=0) |
|
270 |
|
271 # list all records with grading_decision set to fail |
|
272 fields['grade_decision'] = 'fail' |
|
273 |
|
274 # get the list content for all failing records |
|
275 fr_params = list_params.copy() |
|
276 fr_params['list_description'] = \ |
|
277 'List of all Records which have their grading outcome set to fail.' |
|
278 fr_list = lists.getListContent( |
|
279 request, fr_params, fields, idx=1) |
|
280 |
|
281 # list all records with grading decision set to undecided |
|
282 fields['grade_decision'] = 'undecided' |
|
283 |
|
284 # get the list content for all undecided records |
|
285 ur_params = list_params.copy() |
|
286 ur_params['list_description'] = \ |
|
287 'List of all Records which have their grading outcome set to undecided.' |
|
288 ur_list = lists.getListContent( |
|
289 request, ur_params, fields, idx=2) |
|
290 |
|
291 # specify the contents and create a Lists object for use in the context |
|
292 contents = [pr_list, fr_list, ur_list] |
|
293 context['list'] = lists_logic.Lists(contents) |
|
294 |
|
295 return responses.respond(request, template, context) |
|
296 |
207 |
297 |
208 view = View() |
298 view = View() |
209 |
299 |
210 create = decorators.view(view.create) |
300 create = decorators.view(view.create) |
|
301 delete = decorators.view(view.delete) |
211 edit = decorators.view(view.edit) |
302 edit = decorators.view(view.edit) |
212 delete = decorators.view(view.delete) |
303 grading_records = decorators.view(view.gradingRecords) |
213 list = decorators.view(view.list) |
304 list = decorators.view(view.list) |
214 public = decorators.view(view.public) |
305 public = decorators.view(view.public) |