author | Lennard de Rijk <ljvderijk@gmail.com> |
Tue, 11 Aug 2009 10:22:01 -0700 | |
changeset 2754 | efbce6839e90 |
parent 2739 | 22f41aafcedc |
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 |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
32 |
from django import http |
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
33 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
34 |
from soc.logic import dicts |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
from soc.views.helper import decorators |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
46 |
from soc.views.helper import dynaform |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
47 |
from soc.views.helper import forms as forms_helper |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
48 |
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
|
49 |
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
|
50 |
from soc.views.helper import responses |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
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
|
52 |
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
|
53 |
|
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
54 |
import soc.views.helper.forms |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
55 |
|
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
56 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
class View(base.View): |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
"""View methods for the GradingSurveyGroup model. |
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 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
61 |
def __init__(self, params=None): |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
62 |
"""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
|
63 |
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
|
64 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
65 |
Params: |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
66 |
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
|
67 |
""" |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
68 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
69 |
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
|
70 |
rights['create'] = ['checkIsHostForProgramInScope'] |
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
71 |
rights['edit'] = ['checkIsHostForProgramInScope'] |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
72 |
rights['delete'] = ['checkIsDeveloper'] |
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
73 |
rights['show'] = ['checkIsHostForProgramInScope'] |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
74 |
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
|
75 |
rights['records'] = ['checkIsHostForProgramInScope'] |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
76 |
rights['edit_record'] = ['checkIsHostForProgramInScope'] |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
77 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
78 |
new_params = {} |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
79 |
new_params['logic'] = survey_group_logic |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
80 |
new_params['rights'] = rights |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
81 |
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
|
82 |
new_params['sidebar_grouping'] = "Surveys" |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
83 |
|
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
84 |
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
|
85 |
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
|
86 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
87 |
new_params['no_admin'] = True |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
88 |
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
|
89 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
90 |
new_params['create_extra_dynaproperties'] = { |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
91 |
'grading_survey': djangoforms.ModelChoiceField( |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
92 |
GradingProjectSurvey, required=True), |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
93 |
'student_survey': djangoforms.ModelChoiceField(ProjectSurvey, |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
94 |
required=False), |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
95 |
} |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
96 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
97 |
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
|
98 |
'last_update_started', |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
99 |
'last_update_complete'] |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
100 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
101 |
new_params['edit_extra_dynaproperties'] = { |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
102 |
'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
|
103 |
} |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
104 |
|
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
105 |
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 |
(r'^%(url_name)s/(?P<access_type>records)/%(key_fields)s$', |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
107 |
'soc.views.models.%(module_name)s.view_records', |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
108 |
'Overview of GradingRecords'), |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
109 |
(r'^%(url_name)s/(?P<access_type>edit_record)/%(key_fields)s$', |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
110 |
'soc.views.models.%(module_name)s.edit_record', |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
111 |
'Edit a GradingRecord'), |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
112 |
] |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
113 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
114 |
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
|
115 |
|
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
116 |
new_params['view_records_template'] = 'soc/grading_survey_group/records.html' |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
117 |
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
|
118 |
new_params['records_row_template'] = 'soc/grading_record/list/row.html' |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
119 |
new_params['record_edit_template'] = 'soc/grading_record/edit.html' |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
120 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
121 |
# create the form that will be used to edit a GradingRecord |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
122 |
record_logic = survey_group_logic.getRecordLogic() |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
123 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
124 |
record_edit_form = dynaform.newDynaForm( |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
125 |
dynabase=soc.views.helper.forms.BaseForm, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
126 |
dynamodel=record_logic.getModel(), |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
127 |
dynaexclude=['grading_survey_group', 'mentor_record', |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
128 |
'student_record', 'project'], |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
129 |
) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
130 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
131 |
new_params['record_edit_form'] = record_edit_form |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
132 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
133 |
params = dicts.merge(params, new_params) |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
134 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
135 |
super(View, self).__init__(params=params) |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
136 |
|
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
137 |
@decorators.merge_params |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
138 |
@decorators.check_access |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
139 |
def create(self, request, access_type, |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
140 |
page_name=None, params=None, **kwargs): |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
141 |
"""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
|
142 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
143 |
For params see base.View.create(). |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
144 |
""" |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
145 |
|
2610
95949d4c45d9
Add scope view for GradingSurveyGroup and set access checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2589
diff
changeset
|
146 |
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
|
147 |
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
|
148 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
149 |
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
|
150 |
params=params, **kwargs) |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
151 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
152 |
@decorators.merge_params |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
153 |
@decorators.check_access |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
154 |
def edit(self, request, access_type, |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
155 |
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
|
156 |
"""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
|
157 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
158 |
For params see base.View.edit(). |
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 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
161 |
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
|
162 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
163 |
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
|
164 |
params=params, seed=seed, **kwargs) |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
165 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
166 |
def _editGet(self, request, entity, form): |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
167 |
"""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
|
168 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
169 |
Args: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
170 |
request: the django request object |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
171 |
entity: the entity to get |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
172 |
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
|
173 |
""" |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
174 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
175 |
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
|
176 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
177 |
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
|
178 |
|
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
179 |
def _editPost(self, request, entity, fields): |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
180 |
"""See base.View._editPost(). |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
181 |
""" |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
182 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
183 |
if not entity: |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
184 |
# generate a unique link_id |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
185 |
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
|
186 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
187 |
# 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
|
188 |
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
|
189 |
else: |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
190 |
fields['link_id'] = entity.link_id |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
191 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
192 |
# 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
|
193 |
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
|
194 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
195 |
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
|
196 |
"""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
|
197 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
198 |
Args: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
199 |
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
|
200 |
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
|
201 |
""" |
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
202 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
203 |
# fetch the program |
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
204 |
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
|
205 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
206 |
# 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
|
207 |
grading_query = grading_logic.getQueryForFields( |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
208 |
filter={'scope_path':program_keyname}) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
209 |
|
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
210 |
# 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
|
211 |
student_query = project_logic.getQueryForFields( |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
212 |
filter={'scope_path':program_keyname}) |
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 |
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
|
215 |
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
|
216 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
217 |
# use survey titles in drop-downs |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
218 |
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
|
219 |
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
|
220 |
|
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 |
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
|
223 |
"""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
|
224 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
225 |
Args: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
226 |
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
|
227 |
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
|
228 |
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
|
229 |
""" |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
230 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
231 |
# 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
|
232 |
choice_list = [] |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
233 |
|
2589
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
234 |
model = logic.getModel() |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
235 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
236 |
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
|
237 |
if value: |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
238 |
entity = model.get(value) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
239 |
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
|
240 |
choice_list.append((value,text)) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
241 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
242 |
choices = tuple(choice_list) |
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
243 |
|
2ecd4df2c9c7
GradingSurveyGroup now uses DynaForm for its forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2586
diff
changeset
|
244 |
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
|
245 |
|
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
246 |
@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
|
247 |
@decorators.check_access |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
248 |
def viewRecords(self, request, access_type, page_name=None, params=None, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
249 |
**kwargs): |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
250 |
"""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
|
251 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
252 |
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
|
253 |
""" |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
254 |
|
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
255 |
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
|
256 |
|
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
257 |
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
|
258 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
259 |
survey_group_logic = params['logic'] |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
260 |
record_logic = survey_group_logic.getRecordLogic() |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
261 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
262 |
try: |
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
|
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
|
268 |
# 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
|
269 |
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
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
context['entity'] = entity |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
274 |
template = params['view_records_template'] |
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
|
275 |
|
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
276 |
# 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
|
277 |
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
|
278 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
279 |
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
|
280 |
# 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
|
281 |
task_params = { |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
282 |
'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
|
283 |
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
|
284 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
285 |
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
|
286 |
new_task.add() |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
287 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
288 |
# 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
|
289 |
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
|
290 |
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
|
291 |
|
2650
6adbb87b91db
Fixed message on Records page for GradingSurveyGroups.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2649
diff
changeset
|
292 |
context['message'] = 'Grading Records update successfully started.' |
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
|
293 |
|
2619
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
294 |
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
|
295 |
# 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
|
296 |
task_params = { |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
297 |
'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
|
298 |
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
|
299 |
|
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
300 |
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
|
301 |
new_task.add() |
04d4494f518d
The buttons on the GradingSurveyGroup record page now enqueue Tasks.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2612
diff
changeset
|
302 |
|
2650
6adbb87b91db
Fixed message on Records page for GradingSurveyGroups.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2649
diff
changeset
|
303 |
context['message'] = 'Student Projects update successfully started.' |
2648
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
304 |
|
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
305 |
if post_dict.get('update_projects_and_mail'): |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
306 |
# Start the task to update all StudentProjects for the given group and |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
307 |
# send out emails. |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
308 |
task_params = { |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
309 |
'group_key': entity.key().id_or_name(), |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
310 |
'send_mail': 'true'} |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
311 |
task_url = '/tasks/grading_survey_group/update_projects' |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
312 |
|
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
313 |
new_task = taskqueue.Task(params=task_params, url=task_url) |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
314 |
new_task.add() |
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
315 |
|
2650
6adbb87b91db
Fixed message on Records page for GradingSurveyGroups.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2649
diff
changeset
|
316 |
context['message'] = ('Student Projects update successfully started. ' |
6adbb87b91db
Fixed message on Records page for GradingSurveyGroups.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2649
diff
changeset
|
317 |
'And sending out e-mail with the results.') |
2648
c6d1c9ccef4a
Added button to the GradingRecords overview to send mail when updating projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2632
diff
changeset
|
318 |
|
2612
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_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
|
320 |
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
|
321 |
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
|
322 |
list_params['list_row'] = params['records_row_template'] |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
323 |
list_params['list_action'] = (redirects.getEditGradingRecordRedirect, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
324 |
list_params) |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
325 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
326 |
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
|
327 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
328 |
# 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
|
329 |
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
|
330 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
331 |
# 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
|
332 |
pr_params = list_params.copy() |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
333 |
pr_params['list_description'] = \ |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
334 |
'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
|
335 |
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
|
336 |
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
|
337 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
338 |
# 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
|
339 |
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
|
340 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
341 |
# 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
|
342 |
fr_params = list_params.copy() |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
343 |
fr_params['list_description'] = \ |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
344 |
'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
|
345 |
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
|
346 |
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
|
347 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
348 |
# 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
|
349 |
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
|
350 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
351 |
# 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
|
352 |
ur_params = list_params.copy() |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
353 |
ur_params['list_description'] = \ |
2612
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
354 |
'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
|
355 |
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
|
356 |
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
|
357 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
358 |
# 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
|
359 |
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
|
360 |
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
|
361 |
|
216002ba6b86
Added view to GradingSurveyGroup to list all records for a specified group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2610
diff
changeset
|
362 |
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
|
363 |
|
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
364 |
@decorators.merge_params |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
365 |
@decorators.check_access |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
366 |
def editRecord(self, request, access_type, page_name=None, params=None, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
367 |
**kwargs): |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
368 |
"""View in which a GradingRecord can be edited. |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
369 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
370 |
For args see base.View.public(). |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
371 |
""" |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
372 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
373 |
survey_group_logic = params['logic'] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
374 |
record_logic = survey_group_logic.getRecordLogic() |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
375 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
376 |
get_dict = request.GET |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
377 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
378 |
record_id = get_dict.get('id') |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
379 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
380 |
if not (record_id and record_id.isdigit()): |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
381 |
# no valid record_id specified showing the list of GradingRecords |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
382 |
return self._showEditRecordList(request, params, page_name, **kwargs) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
383 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
384 |
# retrieve the wanted GradingRecord |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
385 |
try: |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
386 |
record_entity = record_logic.getFromIDOr404(int(record_id)) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
387 |
except out_of_band.Error, error: |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
388 |
return responses.errorResponse( |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
389 |
error, request, template=params['error_public']) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
390 |
|
2649
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
391 |
survey_group_key_name = survey_group_logic.getKeyNameFromFields(kwargs) |
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
392 |
record_survey_group_key_name = ( |
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
393 |
record_entity.grading_survey_group.key().id_or_name()) |
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
394 |
|
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
395 |
if survey_group_key_name != record_survey_group_key_name: |
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
396 |
# this record does not belong to the given GradingSurveyGroup show list |
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
397 |
return self._showEditRecordList(request, params, page_name, **kwargs) |
7faecb7f2765
Fixed issue where GradingSurveyRecords from another group could be edited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2648
diff
changeset
|
398 |
|
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
399 |
# get the context for this webpage |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
400 |
context = responses.getUniversalContext(request) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
401 |
responses.useJavaScript(context, params['js_uses_all']) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
402 |
context['page_name'] = page_name |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
403 |
context['entity'] = record_entity |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
404 |
template = params['record_edit_template'] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
405 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
406 |
if request.POST: |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
407 |
return self._editRecordPost(request, params, context, template, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
408 |
record_entity) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
409 |
else: # request.GET |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
410 |
return self._editRecordGet(request, params, context, template, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
411 |
record_entity) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
412 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
413 |
def _editRecordGet(self, request, params, context, template, record_entity): |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
414 |
"""Handles the GET request for editing a GradingRecord. |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
415 |
Args: |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
416 |
request: a Django Request object |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
417 |
params: the params for this view |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
418 |
context: the context for the webpage |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
419 |
template: the location of the template used for this view |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
420 |
record_entity: a GradingRecord entity |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
421 |
""" |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
422 |
|
2739
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
423 |
survey_group_logic = params['logic'] |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
424 |
record_logic = survey_group_logic.getRecordLogic() |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
425 |
|
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
426 |
get_dict = request.GET |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
427 |
|
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
428 |
if get_dict.get('update'): |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
429 |
# try to update this record |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
430 |
properties = record_logic.getFieldsForGradingRecord( |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
431 |
record_entity.project, record_entity.grading_survey_group, |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
432 |
record_entity) |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
433 |
record_logic.updateEntityProperties(record_entity, properties) |
22f41aafcedc
Added capability to update a single GradingRecord on the edit page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2651
diff
changeset
|
434 |
|
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
435 |
form = params['record_edit_form'](instance=record_entity) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
436 |
context['form'] = form |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
437 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
438 |
return responses.respond(request, template, context) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
439 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
440 |
def _editRecordPost(self, request, params, context, template, record_entity): |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
441 |
"""Handles the POST request for editing a GradingRecord. |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
442 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
443 |
Args: |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
444 |
request: a Django Request object |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
445 |
params: the params for this view |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
446 |
context: the context for the webpage |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
447 |
template: the location of the template used for this view |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
448 |
record_entity: a GradingRecord entity |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
449 |
""" |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
450 |
|
2651
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
451 |
from google.appengine.api.labs import taskqueue |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
452 |
from soc.logic.models.student_project import logic as student_project_logic |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
453 |
|
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
454 |
survey_logic = params['logic'] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
455 |
record_logic = survey_logic.getRecordLogic() |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
456 |
|
2651
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
457 |
post_dict = request.POST |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
458 |
|
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
459 |
form = params['record_edit_form'](post_dict) |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
460 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
461 |
if not form.is_valid(): |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
462 |
return self._constructResponse(request, record_entity, context, form, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
463 |
params) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
464 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
465 |
_, fields = forms_helper.collectCleanedFields(form) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
466 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
467 |
record_entity = record_logic.updateEntityProperties(record_entity, fields) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
468 |
|
2651
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
469 |
if 'save_update' in post_dict: |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
470 |
# also update the accompanying StudentProject |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
471 |
student_project_logic.updateProjectsForGradingRecords([record_entity]) |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
472 |
elif 'save_update_mail' in post_dict: |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
473 |
# update the StudentProject and send an email about the result |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
474 |
student_project_logic.updateProjectsForGradingRecords([record_entity]) |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
475 |
|
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
476 |
# pass along these params as POST to the new task |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
477 |
task_params = {'record_key': record_entity.key().id_or_name()} |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
478 |
task_url = '/tasks/grading_survey_group/mail_result' |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
479 |
|
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
480 |
mail_task = taskqueue.Task(params=task_params, url=task_url) |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
481 |
mail_task.add('mail') |
842c0f11fc1e
Added the ability to update project + mail when editing a single GradingRecord
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2650
diff
changeset
|
482 |
|
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
483 |
# Redirect to the same page |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
484 |
redirect = request.META['HTTP_REFERER'] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
485 |
return http.HttpResponseRedirect(redirect) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
486 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
487 |
def _showEditRecordList(self, request, params, page_name, **kwargs): |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
488 |
"""Returns a list containing GradingRecords that can be edited. |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
489 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
490 |
For args see base.View.public(). |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
491 |
""" |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
492 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
493 |
survey_group_logic = params['logic'] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
494 |
record_logic = survey_group_logic.getRecordLogic() |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
495 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
496 |
try: |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
497 |
survey_group = survey_group_logic.getFromKeyFieldsOr404(kwargs) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
498 |
except out_of_band.Error, error: |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
499 |
return responses.errorResponse( |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
500 |
error, request, template=params['error_public']) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
501 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
502 |
list_params = params.copy() |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
503 |
list_params['logic'] = record_logic |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
504 |
list_params['list_heading'] = params['records_heading_template'] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
505 |
list_params['list_row'] = params['records_row_template'] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
506 |
list_params['list_action'] = (redirects.getEditGradingRecordRedirect, |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
507 |
list_params) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
508 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
509 |
fields = {'grading_survey_group': survey_group} |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
510 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
511 |
# get the list content for all records |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
512 |
list_params['list_description'] = \ |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
513 |
'List of all GradingRecords. Pick one to edit it.' |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
514 |
list_content = lists.getListContent( |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
515 |
request, list_params, fields, idx=0) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
516 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
517 |
contents = [list_content] |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
518 |
|
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
519 |
# return the view which renders the set content |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
520 |
return self._list(request, list_params, contents, page_name) |
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
521 |
|
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
522 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
523 |
view = View() |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
524 |
|
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
525 |
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
|
526 |
delete = decorators.view(view.delete) |
2585
37584af2420e
Completed the Create and Edit view for GradingSurveyGroup.
Daniel Diniz <ajaksu@gmail.com>
parents:
2580
diff
changeset
|
527 |
edit = decorators.view(view.edit) |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
528 |
edit_record = decorators.view(view.editRecord) |
2580
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
529 |
list = decorators.view(view.list) |
cd3b42f52b21
Added skeleton view and templates for GradingSurveyGroup.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
530 |
public = decorators.view(view.public) |
2632
973e5e7ebd6e
Added view for editing GradingRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2623
diff
changeset
|
531 |
view_records = decorators.view(view.viewRecords) |