author | Lennard de Rijk <ljvderijk@gmail.com> |
Mon, 10 Aug 2009 18:57:00 -0700 | |
changeset 2752 | fb3bed3eecd8 |
parent 2740 | 4b8aa5b9cb23 |
child 2753 | 11d510941d2f |
permissions | -rw-r--r-- |
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for ProjectSurveys. |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
] |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
from soc.logic import dicts |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
from soc.logic.models.survey import project_logic as project_survey_logic |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
27 |
from soc.logic.models.user import logic as user_logic |
2508
17caa9f1c683
Added missing import to ProjectSurvey View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2499
diff
changeset
|
28 |
from soc.views import out_of_band |
2452
4abc27894b61
Added two missing imports to the Project and Grading Surveys views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2448
diff
changeset
|
29 |
from soc.views.helper import access |
4abc27894b61
Added two missing imports to the Project and Grading Surveys views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2448
diff
changeset
|
30 |
from soc.views.helper import decorators |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
31 |
from soc.views.helper import lists |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
32 |
from soc.views.helper import redirects |
2563
eec0d98b38a1
Add missing import to Project Survey view.
Daniel Diniz <ajaksu@gmail.com>
parents:
2549
diff
changeset
|
33 |
from soc.views.helper import responses |
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
34 |
from soc.views.models import survey |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
35 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
36 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
class View(survey.View): |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
38 |
"""View methods for the ProjectSurvey model. |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
39 |
""" |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
def __init__(self, params=None): |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
"""Defines the fields and methods required for the base View class |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
to provide the user with list, public, create, edit and delete views. |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
44 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
45 |
Params: |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
46 |
params: a dict with params for this View |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
47 |
""" |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
48 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
49 |
rights = access.Checker(params) |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
rights['any_access'] = ['allow'] |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
rights['show'] = [('checkIsSurveyReadable', project_survey_logic)] |
2537
990a44b6310b
Returned ProjectSurvey create to checkIsUser.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2536
diff
changeset
|
52 |
rights['create'] = ['checkIsUser'] |
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
rights['edit'] = [('checkIsSurveyWritable', project_survey_logic)] |
2534
c880489123fc
Fixed basic Survey access check.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2532
diff
changeset
|
54 |
rights['delete'] = ['checkIsDeveloper'] # TODO: fix deletion of Surveys |
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
rights['list'] = ['checkDocumentList'] |
2734
f35f6f05c8c4
Added and enabled new access check for viewing ProjectSurvey records.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2725
diff
changeset
|
56 |
rights['record'] = [('checkHasAny', [ |
f35f6f05c8c4
Added and enabled new access check for viewing ProjectSurvey records.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2725
diff
changeset
|
57 |
[('checkIsAllowedToViewProjectSurveyRecordAs', |
f35f6f05c8c4
Added and enabled new access check for viewing ProjectSurvey records.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2725
diff
changeset
|
58 |
[project_survey_logic, 'student', 'id']), |
f35f6f05c8c4
Added and enabled new access check for viewing ProjectSurvey records.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2725
diff
changeset
|
59 |
('checkIsSurveyReadable', [project_survey_logic]), |
f35f6f05c8c4
Added and enabled new access check for viewing ProjectSurvey records.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2725
diff
changeset
|
60 |
]])] |
2722
1ec0af4ddd72
Added view for showing Survey Records.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2686
diff
changeset
|
61 |
rights['results'] = ['checkIsDeveloper'] # TODO: proper access check |
2536
9f1b7aba026f
Added access checks for taking a Project(Grading)Survey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2535
diff
changeset
|
62 |
rights['take'] = [('checkIsSurveyTakeable', project_survey_logic), |
9f1b7aba026f
Added access checks for taking a Project(Grading)Survey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2535
diff
changeset
|
63 |
('checkIsAllowedToTakeProjectSurveyAs', |
9f1b7aba026f
Added access checks for taking a Project(Grading)Survey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2535
diff
changeset
|
64 |
[project_survey_logic, 'student', 'project'])] |
2596
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
65 |
rights['send_reminder'] = ['checkIsDeveloper'] #TODO: proper access check |
2536
9f1b7aba026f
Added access checks for taking a Project(Grading)Survey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2535
diff
changeset
|
66 |
|
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
67 |
new_params = {} |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
68 |
new_params['logic'] = project_survey_logic |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
69 |
new_params['rights'] = rights |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
70 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
71 |
new_params['name'] = "Project Survey" |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
72 |
|
2478
985fd974e095
Clean up and other fixes for Survey modules.
Daniel Diniz <ajaksu@gmail.com>
parents:
2452
diff
changeset
|
73 |
new_params['extra_dynaexclude'] = ['taking_access'] |
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
74 |
|
2596
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
75 |
new_params['extra_django_patterns'] = [ |
2598
59ebf718c6a4
Changed URL pattern for starting sending out survey reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2596
diff
changeset
|
76 |
(r'^%(url_name)s/(?P<access_type>send_reminder)/%(key_fields)s$', |
2596
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
77 |
'soc.views.models.%(module_name)s.send_reminder', |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
78 |
'Send Reminder for %(name)s')] |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
79 |
|
2740
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
80 |
new_params['take_template'] = 'soc/project_survey/take.html' |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
81 |
|
2596
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
82 |
# used for sending reminders |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
83 |
new_params['survey_type'] = 'project' |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
84 |
new_params['reminder_template'] = 'soc/project_survey/reminder.html' |
2740
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
85 |
|
2686
ada26cef0b06
Added new table templates for showing Suryves on the Project manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2598
diff
changeset
|
86 |
new_params['manage_student_project_heading'] = \ |
ada26cef0b06
Added new table templates for showing Suryves on the Project manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2598
diff
changeset
|
87 |
'soc/project_survey/list/heading_manage_student_project.html' |
ada26cef0b06
Added new table templates for showing Suryves on the Project manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2598
diff
changeset
|
88 |
new_params['manage_student_project_row'] = \ |
ada26cef0b06
Added new table templates for showing Suryves on the Project manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2598
diff
changeset
|
89 |
'soc/project_survey/list/row_manage_student_project.html' |
2596
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
90 |
|
2510
a85484d1f441
Ensure that the params from subclasses get merged properly with ProjectSurvey view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2508
diff
changeset
|
91 |
params = dicts.merge(params, new_params, sub_merge=True) |
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
92 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
93 |
super(View, self).__init__(params=params) |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
94 |
|
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
95 |
@decorators.merge_params |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
96 |
@decorators.check_access |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
97 |
def take(self, request, access_type, page_name=None, |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
98 |
params=None, **kwargs): |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
99 |
"""View for taking a Survey. |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
100 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
101 |
For Args see base.View().public(). |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
102 |
""" |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
103 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
104 |
survey_logic = params['logic'] |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
105 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
106 |
try: |
2499
62e8f6e45d9a
Removed unnecessary variable in ProjectSurvey take method.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2498
diff
changeset
|
107 |
entity = survey_logic.getFromKeyFieldsOr404(kwargs) |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
108 |
except out_of_band.Error, error: |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
109 |
return responses.errorResponse( |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
110 |
error, request, template=params['error_public']) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
111 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
112 |
get_dict = request.GET |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
113 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
114 |
if not 'project' in get_dict: |
2531
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
115 |
# get the fields needed to filter projects on |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
116 |
fields = self._constructFilterForProjectSelection(entity, params) |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
117 |
|
2531
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
118 |
# show project selection screen using the given filter |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
119 |
return self._selectProjects(request, page_name, params, entity, fields) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
120 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
121 |
return super(View, self).take(request, 'any_access', page_name=page_name, |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
122 |
params=params, **kwargs) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
123 |
|
2498
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
124 |
def _getSurveyRecordFor(self, survey, request, params): |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
125 |
"""Returns the SurveyRecord for the given Survey and request. |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
126 |
|
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
127 |
This method also take the StudentProject specified as GET param into |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
128 |
account when querying for the SurveyRecord. |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
129 |
|
2531
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
130 |
For params see survey.View._getSurveyRecordFor(). |
2498
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
131 |
""" |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
132 |
|
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
133 |
from soc.logic.models.student_project import logic as student_project_logic |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
134 |
|
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
135 |
survey_logic = params['logic'] |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
136 |
record_logic = survey_logic.getRecordLogic() |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
137 |
|
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
138 |
# get the StudentProject specified in the GET params |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
139 |
project_key_name = request.GET['project'] |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
140 |
project_entity = student_project_logic.getFromKeyName(project_key_name) |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
141 |
|
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
142 |
filter = {'survey': survey, |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
143 |
'project': project_entity} |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
144 |
|
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
145 |
return record_logic.getForFields(filter, unique=True) |
fd51f2159bff
Overwrite _getSurveyRecordFor in ProjectSurvey view to take StudentProject into account.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2494
diff
changeset
|
146 |
|
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
147 |
def _takeGet(self, request, template, context, params, entity, record, |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
148 |
**kwargs): |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
149 |
"""Hooking into the view for the take's page GET request. |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
150 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
151 |
For params see survey.View._takeGet(). |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
152 |
""" |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
153 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
154 |
# the form action should contain the requested project |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
155 |
context['form_action'] = "?project=%s" %(request.GET['project']) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
156 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
157 |
def _takePost(self, request, params, entity, record, properties): |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
158 |
"""Hook into the view for the take's page POST request. |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
159 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
160 |
This is used to ensure the right StudentProject gets stored |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
161 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
162 |
For params see survey.View._takePost(). |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
163 |
""" |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
164 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
165 |
from soc.logic.models.student_project import logic as student_project_logic |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
166 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
167 |
# retrieve the project using the key name in the GET param |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
168 |
get_dict = request.GET |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
169 |
project_entity = student_project_logic.getFromKeyName(get_dict['project']) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
170 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
171 |
# update the properties that will be stored with the referenced project |
2591
6c57c482f913
Add Organization reference property to ProjectSurveyRecord.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2576
diff
changeset
|
172 |
properties.update(project=project_entity, org=project_entity.scope) |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
173 |
|
2740
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
174 |
def _setSurveyTakeContext(self, request, params, context, survey, |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
175 |
survey_record): |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
176 |
"""Sets the context for the ProjectSurvey take page. |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
177 |
|
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
178 |
This includes setting the help_text, status and project_entity. |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
179 |
|
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
180 |
Args: |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
181 |
request: HTTP request object |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
182 |
params: the params for the current View |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
183 |
context: the context for the view to update |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
184 |
survey: a Survey entity |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
185 |
survey_record: a SurveyRecordEntity |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
186 |
""" |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
187 |
|
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
188 |
from soc.logic.models.student_project import logic as student_project_logic |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
189 |
|
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
190 |
# call super first to set the other context items |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
191 |
super(View, self)._setSurveyTakeContext(request, params, context, survey, |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
192 |
survey_record) |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
193 |
|
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
194 |
# retrieve the project using the key name in the GET param |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
195 |
get_dict = request.GET |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
196 |
context['project_entity'] = student_project_logic.getFromKeyName( |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
197 |
get_dict['project']) |
4b8aa5b9cb23
Added project title and student name to the ProjectSurvey take page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2734
diff
changeset
|
198 |
|
2531
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
199 |
def _constructFilterForProjectSelection(self, survey, params): |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
200 |
"""Returns the filter needed for the Project selection view. |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
201 |
|
2532
0b4dbe4b3fb7
Fixed showing the correct list of projects for taking a Grading Project Survey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2531
diff
changeset
|
202 |
Returns a filter for all the valid projects for which the current user |
0b4dbe4b3fb7
Fixed showing the correct list of projects for taking a Grading Project Survey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2531
diff
changeset
|
203 |
is a student. Of course only in the survey's scope. |
0b4dbe4b3fb7
Fixed showing the correct list of projects for taking a Grading Project Survey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2531
diff
changeset
|
204 |
|
2531
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
205 |
Args: |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
206 |
survey: a Survey entity |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
207 |
params: the params dict for the requesting view |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
208 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
209 |
Returns: |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
210 |
Dictionary that can be used as a input for a query. |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
211 |
""" |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
212 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
213 |
from soc.logic.models.student import logic as student_logic |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
214 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
215 |
survey_logic = params['logic'] |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
216 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
217 |
user_entity = user_logic.getForCurrentAccount() |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
218 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
219 |
# get the student entity for the current user and program |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
220 |
fields = {'user': user_entity, |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
221 |
'scope': survey_logic.getScope(survey), |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
222 |
'status': 'active'} |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
223 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
224 |
student_entity = student_logic.getForFields(fields, unique=True) |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
225 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
226 |
fields = {'student': student_entity, |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
227 |
'status': 'accepted'} |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
228 |
|
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
229 |
return fields |
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
230 |
|
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
231 |
def _selectProjects(self, request, page_name, params, survey, fields): |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
232 |
"""Shows a view upon which a User can select a Student Project to fill in |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
233 |
the ProjectSurvey for. |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
234 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
235 |
Args: |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
236 |
survey: a Survey entity |
2531
855ee76c16a2
Refactored filter construction to _constructFilterForProjectSelection.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2510
diff
changeset
|
237 |
fields: the filter to use on the Project List |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
238 |
rest: see base.View.public() |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
239 |
""" |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
240 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
241 |
from soc.views.models.student_project import view as student_project_view |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
242 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
243 |
student_project_params = student_project_view.getParams().copy() |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
244 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
245 |
redirect_dict = {'survey': survey, |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
246 |
'params': params} |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
247 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
248 |
student_project_params['list_action'] = ( |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
249 |
redirects.getTakeProjectSurveyRedirect, redirect_dict) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
250 |
student_project_params['list_description'] = ( |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
251 |
"Select a %s for which to fill in the %s named %s" %( |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
252 |
student_project_params['name'], params['name'], survey.title)) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
253 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
254 |
content = lists.getListContent(request, student_project_params, fields) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
255 |
contents = [content] |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
256 |
|
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
257 |
return self._list(request, student_project_params, contents, page_name) |
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
258 |
|
2596
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
259 |
@decorators.merge_params |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
260 |
@decorators.check_access |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
261 |
def sendReminder(self, request, access_type, page_name=None, |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
262 |
params=None, **kwargs): |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
263 |
"""Starts the task to send out reminders for the Survey given in kwargs. |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
264 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
265 |
For args see base.View.public(). |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
266 |
""" |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
267 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
268 |
from google.appengine.api.labs import taskqueue |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
269 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
270 |
from django import http |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
271 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
272 |
survey_logic = params['logic'] |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
273 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
274 |
try: |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
275 |
entity = survey_logic.getFromKeyFieldsOr404(kwargs) |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
276 |
except out_of_band.Error, error: |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
277 |
return responses.errorResponse( |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
278 |
error, request, template=params['error_public']) |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
279 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
280 |
# get the context for this webpage |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
281 |
context = responses.getUniversalContext(request) |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
282 |
context['page_name'] = page_name |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
283 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
284 |
if request.POST and request.POST.get('start'): |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
285 |
# button has been pressed start the task |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
286 |
task_params = { |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
287 |
'program_key': survey_logic.getScope(entity).key().id_or_name(), |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
288 |
'survey_key': entity.key().id_or_name(), |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
289 |
'survey_type': params['survey_type']} |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
290 |
task_url = '/tasks/surveys/projects/send_reminder/spawn' |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
291 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
292 |
new_task = taskqueue.Task(params=task_params, url=task_url) |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
293 |
new_task.add() |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
294 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
295 |
context['message'] = "Task successfully started!" |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
296 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
297 |
template = params['reminder_template'] |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
298 |
return responses.respond(request, template, context) |
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
299 |
|
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
300 |
|
2448
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
301 |
view = View() |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
302 |
|
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
303 |
create = decorators.view(view.create) |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
304 |
edit = decorators.view(view.edit) |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
305 |
delete = decorators.view(view.delete) |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
306 |
list = decorators.view(view.list) |
325e08ee9d25
Added skeleton view for ProjectSurvey and GradingProjectSurvey.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
307 |
public = decorators.view(view.public) |
2722
1ec0af4ddd72
Added view for showing Survey Records.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2686
diff
changeset
|
308 |
record = decorators.view(view.viewRecord) |
2576
7a1138f8a0e2
Removed results list from Survey edit.
Daniel Diniz <ajaksu@gmail.com>
parents:
2563
diff
changeset
|
309 |
results = decorators.view(view.viewResults) |
2596
56924ec61cd2
Added a view to start sending out a reminder.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2591
diff
changeset
|
310 |
send_reminder = decorators.view(view.sendReminder) |
2494
c312f1b1939c
Implemented taking ProjectSurveys.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2478
diff
changeset
|
311 |
take = decorators.view(view.take) |