author | Lennard de Rijk <ljvderijk@gmail.com> |
Mon, 13 Jul 2009 01:15:46 +0200 | |
changeset 2623 | 9848682af610 |
parent 2619 | 04d4494f518d |
child 2632 | 973e5e7ebd6e |
permissions | -rw-r--r-- |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for GradingSurveyGroup. |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
21 |
'"Daniel Diniz" <ajaksu@gmail.com>', |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
] |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
|
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
26 |
import datetime |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
27 |
import time |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
28 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
29 |
from google.appengine.ext.db import djangoforms |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
30 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
31 |
from django import forms |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
32 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
from soc.logic import dicts |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
34 |
from soc.logic.models.program import logic as program_logic |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
35 |
from soc.logic.models.survey import grading_logic |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
36 |
from soc.logic.models.survey import project_logic |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
37 |
from soc.logic.models.user import logic as user_logic |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
38 |
from soc.logic.models.grading_survey_group import logic as survey_group_logic |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
39 |
from soc.models.grading_survey_group import GradingSurveyGroup |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
40 |
from soc.models.grading_project_survey import GradingProjectSurvey |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
41 |
from soc.models.project_survey import ProjectSurvey |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
42 |
from soc.views import out_of_band |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
from soc.views.helper import access |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
44 |
from soc.views.helper import decorators |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
45 |
from soc.views.helper import lists |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
46 |
from soc.views.helper import redirects |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
47 |
from soc.views.helper import responses |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
48 |
from soc.views.models import base |
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
49 |
from soc.views.models import program as program_view |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
|
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
51 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
52 |
class View(base.View): |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
"""View methods for the GradingSurveyGroup model. |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
54 |
""" |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
56 |
def __init__(self, params=None): |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
"""Defines the fields and methods required for the base View class |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
to provide the user with list, public, create, edit and delete views. |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
59 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
60 |
Params: |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
61 |
params: a dict with params for this View |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
62 |
""" |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
63 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
64 |
rights = access.Checker(params) |
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
65 |
rights['create'] = ['checkIsHostForProgramInScope'] |
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
66 |
rights['edit'] = ['checkIsHostForProgramInScope'] |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
67 |
rights['delete'] = ['checkIsDeveloper'] |
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
68 |
rights['show'] = ['checkIsHostForProgramInScope'] |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
69 |
rights['list'] = ['checkIsDeveloper'] |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
70 |
rights['records'] = ['checkIsHostForProgramInScope'] |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
71 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
72 |
new_params = {} |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
73 |
new_params['logic'] = survey_group_logic |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
74 |
new_params['rights'] = rights |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
75 |
new_params['name'] = "Grading Survey Group" |
2586
283bb903b216
Added GradingSurveyGroup to the sitemap and sidebar.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2585
diff
changeset
|
76 |
new_params['sidebar_grouping'] = "Surveys" |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
77 |
|
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
78 |
new_params['scope_view'] = program_view |
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
79 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
80 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
81 |
new_params['no_admin'] = True |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
82 |
new_params['no_create_with_key_fields'] = True |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
83 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
84 |
new_params['create_extra_dynaproperties'] = { |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
85 |
'grading_survey': djangoforms.ModelChoiceField( |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
86 |
GradingProjectSurvey, required=True), |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
87 |
'student_survey': djangoforms.ModelChoiceField(ProjectSurvey, |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
88 |
required=False), |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
89 |
} |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
90 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
91 |
new_params['extra_dynaexclude'] = ['link_id', 'scope', 'scope_path', |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
92 |
'last_update_started', |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
93 |
'last_update_complete'] |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
94 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
95 |
new_params['edit_extra_dynaproperties'] = { |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
96 |
'link_id': forms.CharField(widget=forms.HiddenInput), |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
97 |
} |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
98 |
|
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
99 |
patterns = [ |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
100 |
(r'^%(url_name)s/(?P<access_type>records)/%(key_fields)s$', |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
101 |
'soc.views.models.%(module_name)s.grading_records', |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
102 |
'Overview of GradingRecords'), |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
103 |
] |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
104 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
105 |
new_params['extra_django_patterns'] = patterns |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
106 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
107 |
new_params['records_template'] = 'soc/grading_survey_group/records.html' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
108 |
new_params['records_heading_template'] = 'soc/grading_record/list/heading.html' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
109 |
new_params['records_row_template'] = 'soc/grading_record/list/row.html' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
110 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
111 |
params = dicts.merge(params, new_params) |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
112 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
113 |
super(View, self).__init__(params=params) |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
114 |
|
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
115 |
@decorators.merge_params |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
116 |
@decorators.check_access |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
117 |
def create(self, request, access_type, |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
118 |
page_name=None, params=None, **kwargs): |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
119 |
"""Pass the correct survey queries to GroupForm. |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
120 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
121 |
For params see base.View.create(). |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
122 |
""" |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
123 |
|
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
124 |
if kwargs.get('scope_path'): |
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
125 |
self.setQueries(kwargs['scope_path'], params['create_form']) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
126 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
127 |
return super(View, self).create(request, access_type, page_name=page_name, |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
128 |
params=params, **kwargs) |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
129 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
130 |
@decorators.merge_params |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
131 |
@decorators.check_access |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
132 |
def edit(self, request, access_type, |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
133 |
page_name=None, params=None, seed=None, **kwargs): |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
134 |
"""Pass the correct survey queries to GroupForm. |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
135 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
136 |
For params see base.View.edit(). |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
137 |
""" |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
138 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
139 |
self.setQueries(kwargs['scope_path'], params['edit_form']) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
140 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
141 |
return super(View, self).edit(request, access_type, page_name=page_name, |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
142 |
params=params, seed=seed, **kwargs) |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
143 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
144 |
def _editGet(self, request, entity, form): |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
145 |
"""Performs any required processing on the form to get its edit page. |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
146 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
147 |
Args: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
148 |
request: the django request object |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
149 |
entity: the entity to get |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
150 |
form: the django form that will be used for the page |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
151 |
""" |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
152 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
153 |
form.fields['link_id'].initial = entity.link_id |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
154 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
155 |
return super(View,self)._editGet(request, entity,form) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
156 |
|
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
157 |
def _editPost(self, request, entity, fields): |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
158 |
"""See base.View._editPost(). |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
159 |
""" |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
160 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
161 |
if not entity: |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
162 |
# generate a unique link_id |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
163 |
fields['link_id'] = 't%i' % (int(time.time()*100)) |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
164 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
165 |
# TODO: seriously redesign _editPost to pass along kwargs |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
166 |
fields['scope_path'] = fields['grading_survey'].scope_path |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
167 |
else: |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
168 |
fields['link_id'] = entity.link_id |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
169 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
170 |
# fill in the scope via call to super |
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
171 |
return super(View, self)._editPost(request, entity, fields) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
172 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
173 |
def setQueries(self, program_keyname, group_form): |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
174 |
"""Add program filtering queries to the GroupForm. |
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
175 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
176 |
Args: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
177 |
program_keyname: keyname of the program to filter on |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
178 |
group_form: DynaForm instance to set the queries for |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
179 |
""" |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
180 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
181 |
# fetch the program |
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
182 |
program = program_logic.getFromKeyNameOr404(program_keyname) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
183 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
184 |
# filter grading surveys by program and use title for display |
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
185 |
grading_query = grading_logic.getQueryForFields( |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
186 |
filter={'scope_path':program_keyname}) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
187 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
188 |
# filter project surveys by program and use title for display |
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
189 |
student_query = project_logic.getQueryForFields( |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
190 |
filter={'scope_path':program_keyname}) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
191 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
192 |
group_form.base_fields['grading_survey'].query = grading_query |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
193 |
group_form.base_fields['student_survey'].query = student_query |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
194 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
195 |
# use survey titles in drop-downs |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
196 |
self.choiceTitles(group_form, 'grading_survey', grading_logic) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
197 |
self.choiceTitles(group_form, 'student_survey', project_logic) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
198 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
199 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
200 |
def choiceTitles(self, group_form, field, logic): |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
201 |
"""Fetch entity titles for choice field entries. |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
202 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
203 |
Args: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
204 |
group_form: The form to set the choice field entries for |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
205 |
field: the field_name to set the choice entries for |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
206 |
logic: the logic for the model to set the choice entries for |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
207 |
""" |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
208 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
209 |
# TODO(ajaksu): subclass ModelChoiceField so we don't need this method |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
210 |
choice_list = [] |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
211 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
212 |
model = logic.getModel() |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
213 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
214 |
for value, text in tuple(group_form.base_fields[field].choices): |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
215 |
if value: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
216 |
entity = model.get(value) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
217 |
text = '%s (%s)' % (entity.title, entity.link_id) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
218 |
choice_list.append((value,text)) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
219 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
220 |
choices = tuple(choice_list) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
221 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
222 |
group_form.base_fields[field].choices = choices |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
223 |
|
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
224 |
@decorators.merge_params |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
225 |
@decorators.check_access |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
226 |
def gradingRecords(self, request, access_type, page_name=None, params=None, |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
227 |
**kwargs): |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
228 |
"""View which shows all collected records for a given GradingSurveyGroup. |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
229 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
230 |
For args see base.View.public(). |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
231 |
""" |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
232 |
|
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
233 |
from google.appengine.api.labs import taskqueue |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
234 |
|
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
235 |
from soc.logic import lists as lists_logic |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
236 |
from soc.logic.models.grading_record import logic as record_logic |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
237 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
238 |
survey_group_logic = params['logic'] |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
239 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
240 |
try: |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
241 |
entity = survey_group_logic.getFromKeyFieldsOr404(kwargs) |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
242 |
except out_of_band.Error, error: |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
243 |
return responses.errorResponse( |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
244 |
error, request, template=params['error_public']) |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
245 |
|
2623
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
246 |
# get the context for this webpage |
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
247 |
context = responses.getUniversalContext(request) |
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
248 |
responses.useJavaScript(context, params['js_uses_all']) |
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
249 |
context['page_name'] = "%s for %s named '%s'" %( |
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
250 |
page_name, params['name'], entity.name) |
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
251 |
context['entity'] = entity |
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
252 |
|
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
253 |
# get the POST request dictionary and check if we should take action |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
254 |
post_dict = request.POST |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
255 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
256 |
if post_dict.get('update_records'): |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
257 |
# start the task to update all GradingRecords for the given group |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
258 |
task_params = { |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
259 |
'group_key': entity.key().id_or_name()} |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
260 |
task_url = '/tasks/grading_survey_group/update_records' |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
261 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
262 |
new_task = taskqueue.Task(params=task_params, url=task_url) |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
263 |
new_task.add() |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
264 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
265 |
# update the GradingSurveyGroup with the new timestamp |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
266 |
fields = {'last_update_started': datetime.datetime.now()} |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
267 |
survey_group_logic.updateEntityProperties(entity, fields) |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
268 |
|
2623
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
269 |
context['message'] = 'Updating GradingRecords successfully started' |
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
270 |
|
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
271 |
if post_dict.get('update_projects'): |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
272 |
# start the task to update all StudentProjects for the given group |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
273 |
task_params = { |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
274 |
'group_key': entity.key().id_or_name()} |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
275 |
task_url = '/tasks/grading_survey_group/update_projects' |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
276 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
277 |
new_task = taskqueue.Task(params=task_params, url=task_url) |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
278 |
new_task.add() |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
279 |
|
2623
9848682af610
Added messages to the Records page when a task has been successfully started.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2619
diff
changeset
|
280 |
context['message'] = 'Updating StudentProjects successfully started' |
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
281 |
|
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
282 |
template = params['records_template'] |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
283 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
284 |
list_params = params.copy() |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
285 |
list_params['logic'] = record_logic |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
286 |
list_params['list_heading'] = params['records_heading_template'] |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
287 |
list_params['list_row'] = params['records_row_template'] |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
288 |
# TODO(ljvderijk) proper redirect to edit a record |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
289 |
list_params['list_action'] = None |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
290 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
291 |
fields = {'grading_survey_group': entity} |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
292 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
293 |
# list all records with grading_decision set to pass |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
294 |
fields['grade_decision'] = 'pass' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
295 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
296 |
# get the list content for passing records |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
297 |
pr_params = list_params.copy() |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
298 |
pr_params['list_description'] = \ |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
299 |
'List of all Records which have their grading outcome set to pass.' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
300 |
pr_list = lists.getListContent( |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
301 |
request, pr_params, fields, idx=0) |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
302 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
303 |
# list all records with grading_decision set to fail |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
304 |
fields['grade_decision'] = 'fail' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
305 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
306 |
# get the list content for all failing records |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
307 |
fr_params = list_params.copy() |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
308 |
fr_params['list_description'] = \ |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
309 |
'List of all Records which have their grading outcome set to fail.' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
310 |
fr_list = lists.getListContent( |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
311 |
request, fr_params, fields, idx=1) |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
312 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
313 |
# list all records with grading decision set to undecided |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
314 |
fields['grade_decision'] = 'undecided' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
315 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
316 |
# get the list content for all undecided records |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
317 |
ur_params = list_params.copy() |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
318 |
ur_params['list_description'] = \ |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
319 |
'List of all Records which have their grading outcome set to undecided.' |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
320 |
ur_list = lists.getListContent( |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
321 |
request, ur_params, fields, idx=2) |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
322 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
323 |
# specify the contents and create a Lists object for use in the context |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
324 |
contents = [pr_list, fr_list, ur_list] |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
325 |
context['list'] = lists_logic.Lists(contents) |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
326 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
327 |
return responses.respond(request, template, context) |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
328 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
329 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
330 |
view = View() |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
331 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
332 |
create = decorators.view(view.create) |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
333 |
delete = decorators.view(view.delete) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
334 |
edit = decorators.view(view.edit) |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
335 |
grading_records = decorators.view(view.gradingRecords) |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
336 |
list = decorators.view(view.list) |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
337 |
public = decorators.view(view.public) |