author | Madhusudan.C.S <madhusudancs@gmail.com> |
Tue, 15 Sep 2009 20:54:40 +0200 | |
changeset 2922 | 6e373954bbf6 |
parent 2856 | f446e019825c |
child 2970 | 605e3c3a55e9 |
permissions | -rw-r--r-- |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Student Project. |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
] |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
25 |
import logging |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
import time |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
27 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
28 |
from django import forms |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
29 |
from django import http |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
30 |
from django.utils.translation import ugettext |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic import cleaning |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
from soc.logic import dicts |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
34 |
from soc.logic.models import mentor as mentor_logic |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
35 |
from soc.logic.models.organization import logic as org_logic |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
36 |
from soc.logic.models.org_admin import logic as org_admin_logic |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
from soc.logic.models import student as student_logic |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
38 |
from soc.logic.models.program import logic as program_logic |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
39 |
from soc.logic.models.student_project import logic as project_logic |
2117
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
40 |
from soc.views import out_of_band |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
from soc.views.helper import access |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
from soc.views.helper import decorators |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
43 |
from soc.views.helper import dynaform |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
44 |
from soc.views.helper import forms as forms_helper |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
45 |
from soc.views.helper import lists |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
46 |
from soc.views.helper import params as params_helper |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
47 |
from soc.views.helper import redirects |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
48 |
from soc.views.helper import responses |
2125
c24e8423cd1a
Added public info as TinyMCE to the edit pages.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2122
diff
changeset
|
49 |
from soc.views.helper import widgets |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
from soc.views.models import base |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
from soc.views.models import organization as org_view |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
52 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
import soc.logic.models.student_project |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
54 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
56 |
class View(base.View): |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
"""View methods for the Student Project model. |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
""" |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
59 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
60 |
def __init__(self, params=None): |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
61 |
"""Defines the fields and methods required for the base View class |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
62 |
to provide the user with list, public, create, edit and delete views. |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
63 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
64 |
Params: |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
65 |
params: a dict with params for this View |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
66 |
""" |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
67 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
68 |
rights = access.Checker(params) |
2241
5e5b7f5d9a89
Allow anyone to see student projects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2183
diff
changeset
|
69 |
rights['any_access'] = ['allow'] |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
70 |
rights['create'] = ['checkIsDeveloper'] |
2076
1cd180cc56c9
Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1936
diff
changeset
|
71 |
rights['edit'] = ['checkIsDeveloper'] |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
72 |
rights['delete'] = ['checkIsDeveloper'] |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
73 |
rights['show'] = ['allow'] |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
74 |
rights['list'] = ['checkIsDeveloper'] |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
75 |
rights['manage'] = [('checkHasActiveRoleForScope', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
76 |
org_admin_logic), |
2743
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
77 |
('checkStudentProjectHasStatus', [['accepted', 'failed', 'completed', |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
78 |
'withdrawn']])] |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
79 |
rights['manage_overview'] = [('checkHasActiveRoleForScope', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
80 |
org_admin_logic)] |
2360
e389d26949db
Style and pylint fixes in Melange modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2330
diff
changeset
|
81 |
# TODO: lack of better name here! |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
82 |
rights['st_edit'] = ['checkIsMyStudentProject', |
2152
3c3f0cd9873d
Brown paper bag fix for Student Project Manage and Edit access check.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2146
diff
changeset
|
83 |
('checkStudentProjectHasStatus', |
2573
f09f317769c4
Changed the StudentProject model to handle a dynamic amount of GradeRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
84 |
[['accepted', 'completed']]) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
85 |
] |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
86 |
rights['withdraw'] = ['checkIsHostForProgram'] |
2711
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
87 |
rights['withdraw_project'] = ['checkIsHostForStudentProject', |
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
88 |
('checkStudentProjectHasStatus', |
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
89 |
[['accepted', 'completed']]) |
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
90 |
] |
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
91 |
rights['accept_project'] = ['checkIsHostForStudentProject', |
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
92 |
('checkStudentProjectHasStatus', |
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
93 |
[['withdrawn']]) |
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
94 |
] |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
95 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
96 |
new_params = {} |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
97 |
new_params['logic'] = soc.logic.models.student_project.logic |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
98 |
new_params['rights'] = rights |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
99 |
new_params['name'] = "Student Project" |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
100 |
new_params['url_name'] = "student_project" |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
101 |
new_params['sidebar_grouping'] = 'Students' |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
102 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
103 |
new_params['scope_view'] = org_view |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
104 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
105 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
106 |
new_params['no_create_with_key_fields'] = True |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
107 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
108 |
new_params['extra_dynaexclude'] = ['program', 'status', 'link_id', |
2183
4e036dcc79ba
Added additional_mentors property to StudentProject.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2177
diff
changeset
|
109 |
'mentor', 'additional_mentors', |
2637
0ae090b18a5e
Excluded the new StudentProject failed_evaluations property from Forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2573
diff
changeset
|
110 |
'student', 'passed_evaluations', |
0ae090b18a5e
Excluded the new StudentProject failed_evaluations property from Forms.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2573
diff
changeset
|
111 |
'failed_evaluations'] |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
112 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
113 |
new_params['create_extra_dynaproperties'] = { |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
114 |
'scope_path': forms.CharField(widget=forms.HiddenInput, |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
115 |
required=True), |
2125
c24e8423cd1a
Added public info as TinyMCE to the edit pages.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2122
diff
changeset
|
116 |
'public_info': forms.fields.CharField(required=True, |
c24e8423cd1a
Added public info as TinyMCE to the edit pages.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2122
diff
changeset
|
117 |
widget=widgets.FullTinyMCE(attrs={'rows': 25, 'cols': 100})), |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
118 |
'student_id': forms.CharField(label='Student Link ID', |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
119 |
required=True), |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
120 |
'mentor_id': forms.CharField(label='Mentor Link ID', |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
121 |
required=True), |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
122 |
'clean_abstract': cleaning.clean_content_length('abstract'), |
2125
c24e8423cd1a
Added public info as TinyMCE to the edit pages.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2122
diff
changeset
|
123 |
'clean_public_info': cleaning.clean_html_content('public_info'), |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
124 |
'clean_student': cleaning.clean_link_id('student'), |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
125 |
'clean_mentor': cleaning.clean_link_id('mentor'), |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
126 |
'clean_additional_info': cleaning.clean_url('additional_info'), |
2122
b709f9d1566a
Added feed_url to StudentProject.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2121
diff
changeset
|
127 |
'clean_feed_url': cleaning.clean_feed_url, |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
128 |
'clean': cleaning.validate_student_project('scope_path', |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
129 |
'mentor_id', 'student_id') |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
130 |
} |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
131 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
132 |
new_params['edit_extra_dynaproperties'] = { |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
133 |
'link_id': forms.CharField(widget=forms.HiddenInput), |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
134 |
} |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
135 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
136 |
patterns = [ |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
137 |
(r'^%(url_name)s/(?P<access_type>manage_overview)/%(scope)s$', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
138 |
'soc.views.models.%(module_name)s.manage_overview', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
139 |
'Overview of %(name_plural)s to Manage for'), |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
140 |
(r'^%(url_name)s/(?P<access_type>manage)/%(key_fields)s$', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
141 |
'soc.views.models.%(module_name)s.manage', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
142 |
'Manage %(name)s'), |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
143 |
(r'^%(url_name)s/(?P<access_type>st_edit)/%(key_fields)s$', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
144 |
'soc.views.models.%(module_name)s.st_edit', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
145 |
'Edit my %(name)s'), |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
146 |
(r'^%(url_name)s/(?P<access_type>withdraw)/(?P<scope_path>%(ulnp)s)/%(lnp)s$', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
147 |
'soc.views.models.%(module_name)s.withdraw', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
148 |
'Withdraw %(name_plural)s'), |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
149 |
(r'^%(url_name)s/(?P<access_type>withdraw_project)/%(key_fields)s$', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
150 |
'soc.views.models.%(module_name)s.withdraw_project', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
151 |
'Withdraw a %(name)s'), |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
152 |
(r'^%(url_name)s/(?P<access_type>accept_project)/%(key_fields)s$', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
153 |
'soc.views.models.%(module_name)s.accept_project', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
154 |
'Accept a %(name)s'), |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
155 |
] |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
156 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
157 |
new_params['extra_django_patterns'] = patterns |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
158 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
159 |
new_params['edit_template'] = 'soc/student_project/edit.html' |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
160 |
new_params['manage_template'] = 'soc/student_project/manage.html' |
2685
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
161 |
new_params['manage_overview_heading'] = \ |
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
162 |
'soc/student_project/list/heading_manage.html' |
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
163 |
new_params['manage_overview_row'] = \ |
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
164 |
'soc/student_project/list/row_manage.html' |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
165 |
|
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
166 |
params = dicts.merge(params, new_params) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
167 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
168 |
super(View, self).__init__(params=params) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
169 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
170 |
# create the form that students will use to edit their projects |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
171 |
dynaproperties = { |
2125
c24e8423cd1a
Added public info as TinyMCE to the edit pages.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2122
diff
changeset
|
172 |
'public_info': forms.fields.CharField(required=True, |
c24e8423cd1a
Added public info as TinyMCE to the edit pages.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2122
diff
changeset
|
173 |
widget=widgets.FullTinyMCE(attrs={'rows': 25, 'cols': 100})), |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
174 |
'clean_abstract': cleaning.clean_content_length('abstract'), |
2125
c24e8423cd1a
Added public info as TinyMCE to the edit pages.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2122
diff
changeset
|
175 |
'clean_public_info': cleaning.clean_html_content('public_info'), |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
176 |
'clean_additional_info': cleaning.clean_url('additional_info'), |
2122
b709f9d1566a
Added feed_url to StudentProject.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2121
diff
changeset
|
177 |
'clean_feed_url': cleaning.clean_feed_url, |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
178 |
} |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
179 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
180 |
student_edit_form = dynaform.newDynaForm( |
2177
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2154
diff
changeset
|
181 |
dynabase = self._params['dynabase'], |
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2154
diff
changeset
|
182 |
dynamodel = self._params['logic'].getModel(), |
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2154
diff
changeset
|
183 |
dynaexclude = self._params['create_dynaexclude'], |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
184 |
dynaproperties = dynaproperties, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
185 |
) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
186 |
|
2177
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2154
diff
changeset
|
187 |
self._params['student_edit_form'] = student_edit_form |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
188 |
|
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
189 |
def _editGet(self, request, entity, form): |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
190 |
"""See base.View._editGet(). |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
191 |
""" |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
192 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
193 |
form.fields['link_id'].initial = entity.link_id |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
194 |
form.fields['student_id'].initial = entity.student.link_id |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
195 |
form.fields['mentor_id'].initial = entity.mentor.link_id |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
196 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
197 |
return super(View, self)._editGet(request, entity, form) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
198 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
199 |
def _editPost(self, request, entity, fields): |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
200 |
"""See base.View._editPost(). |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
201 |
""" |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
202 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
203 |
if not entity: |
2076
1cd180cc56c9
Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1936
diff
changeset
|
204 |
fields['link_id'] = 't%i' % (int(time.time()*100)) |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
205 |
else: |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
206 |
fields['link_id'] = entity.link_id |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
207 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
208 |
# fill in the scope via call to super |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
209 |
super(View, self)._editPost(request, entity, fields) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
210 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
211 |
# editing a project so set the program, student and mentor field |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
212 |
if entity: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
213 |
organization = entity.scope |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
214 |
else: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
215 |
organization = fields['scope'] |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
216 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
217 |
fields['program'] = organization.scope |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
218 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
219 |
filter = {'scope': fields['program'], |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
220 |
'link_id': fields['student_id']} |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
221 |
fields['student'] = student_logic.logic.getForFields(filter, unique=True) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
222 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
223 |
filter = {'scope': organization, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
224 |
'link_id': fields['mentor_id'], |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
225 |
'status': 'active'} |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
226 |
fields['mentor'] = mentor_logic.logic.getForFields(filter, unique=True) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
227 |
|
2280
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
228 |
def _public(self, request, entity, context): |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
229 |
"""Adds the names of all additional mentors to the context. |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
230 |
|
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
231 |
For params see base.View._public() |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
232 |
""" |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
233 |
|
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
234 |
additional_mentors = entity.additional_mentors |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
235 |
|
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
236 |
if not additional_mentors: |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
237 |
context['additional_mentors'] = [] |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
238 |
else: |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
239 |
mentor_names = [] |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
240 |
|
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
241 |
for mentor_key in additional_mentors: |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
242 |
additional_mentor = mentor_logic.logic.getFromKeyName( |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
243 |
mentor_key.id_or_name()) |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
244 |
mentor_names.append(additional_mentor.name()) |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
245 |
|
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
246 |
context['additional_mentors'] = ', '.join(mentor_names) |
157f6b8de010
Show all Co-Mentors on the Student Project public page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2279
diff
changeset
|
247 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
248 |
@decorators.merge_params |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
249 |
@decorators.check_access |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
250 |
def withdraw(self, request, access_type, |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
251 |
page_name=None, params=None, **kwargs): |
2711
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
252 |
"""View that allows Program Admins to accept or withdraw Student Projects. |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
253 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
254 |
For params see base.View().public() |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
255 |
""" |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
256 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
257 |
program = program_logic.getFromKeyFieldsOr404(kwargs) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
258 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
259 |
fields = { |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
260 |
'program': program, |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
261 |
'status': ['accepted', 'completed'], |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
262 |
} |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
263 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
264 |
ap_params = params.copy() # accepted projects |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
265 |
|
2715
afd5368af75c
Added some helpful text to the Student Project Withdraw view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2711
diff
changeset
|
266 |
ap_params['list_action'] = (redirects.getWithdrawProjectRedirect, |
afd5368af75c
Added some helpful text to the Student Project Withdraw view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2711
diff
changeset
|
267 |
ap_params) |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
268 |
ap_params['list_description'] = ugettext( |
2717
fdde098394a7
Fixed typo in access module comment and StudentProject list description.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2715
diff
changeset
|
269 |
"An overview of accepted and completed Projects. " |
2715
afd5368af75c
Added some helpful text to the Student Project Withdraw view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2711
diff
changeset
|
270 |
"Click on a project to withdraw it.") |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
271 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
272 |
ap_list = lists.getListContent( |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
273 |
request, ap_params, fields, idx=0) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
274 |
|
2711
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
275 |
fields['status'] = ['withdrawn'] |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
276 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
277 |
wp_params = params.copy() # withdrawn projects |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
278 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
279 |
wp_params['list_action'] = (redirects.getAcceptProjectRedirect, wp_params) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
280 |
wp_params['list_description'] = ugettext( |
2717
fdde098394a7
Fixed typo in access module comment and StudentProject list description.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2715
diff
changeset
|
281 |
"An overview of withdrawn Projects. " |
2715
afd5368af75c
Added some helpful text to the Student Project Withdraw view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2711
diff
changeset
|
282 |
"Click on a project to undo the withdrawal.") |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
283 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
284 |
wp_list = lists.getListContent( |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
285 |
request, wp_params, fields, idx=1) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
286 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
287 |
# fill contents with all the needed lists |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
288 |
contents = [ap_list, wp_list] |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
289 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
290 |
# call the _list method from base to display the list |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
291 |
return self._list(request, params, contents, page_name) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
292 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
293 |
@decorators.merge_params |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
294 |
@decorators.check_access |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
295 |
def withdrawProject(self, request, access_type, |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
296 |
page_name=None, params=None, **kwargs): |
2711
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
297 |
"""View that allows Program Admins to withdraw Student Projects. |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
298 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
299 |
For params see base.View().public() |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
300 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
301 |
""" |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
302 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
303 |
logic = params['logic'] |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
304 |
entity = logic.getFromKeyFieldsOr404(kwargs) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
305 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
306 |
fields = { |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
307 |
'status': 'withdrawn', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
308 |
} |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
309 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
310 |
logic.updateEntityProperties(entity, fields) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
311 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
312 |
url = redirects.getWithdrawRedirect(entity.program, params) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
313 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
314 |
return http.HttpResponseRedirect(url) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
315 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
316 |
@decorators.merge_params |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
317 |
@decorators.check_access |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
318 |
def acceptProject(self, request, access_type, |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
319 |
page_name=None, params=None, **kwargs): |
2711
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
320 |
"""View that allows Program Admins to accept Student Projects. |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
321 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
322 |
For params see base.View().public() |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
323 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
324 |
""" |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
325 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
326 |
logic = params['logic'] |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
327 |
entity = logic.getFromKeyFieldsOr404(kwargs) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
328 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
329 |
fields = { |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
330 |
'status': 'accepted', |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
331 |
} |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
332 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
333 |
logic.updateEntityProperties(entity, fields) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
334 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
335 |
url = redirects.getWithdrawRedirect(entity.program, params) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
336 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
337 |
return http.HttpResponseRedirect(url) |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
338 |
|
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
339 |
@decorators.merge_params |
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
340 |
@decorators.check_access |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
341 |
def manage(self, request, access_type, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
342 |
page_name=None, params=None, **kwargs): |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
343 |
"""View that allows Organization Admins to manage their Student Projects. |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
344 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
345 |
For params see base.View().public() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
346 |
""" |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
347 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
348 |
try: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
349 |
entity = self._logic.getFromKeyFieldsOr404(kwargs) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
350 |
except out_of_band.Error, error: |
2117
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
351 |
return responses.errorResponse( |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
352 |
error, request, template=params['error_public']) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
353 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
354 |
template = params['manage_template'] |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
355 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
356 |
# get the context for this webpage |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
357 |
context = responses.getUniversalContext(request) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
358 |
responses.useJavaScript(context, params['js_uses_all']) |
2117
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
359 |
context['page_name'] = "%s '%s' from %s" % (page_name, entity.title, |
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
360 |
entity.student.name()) |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
361 |
context['entity'] = entity |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
362 |
|
2743
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
363 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
364 |
if entity.status == 'accepted': |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
365 |
# only accepted project can have their mentors managed |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
366 |
self._enableMentorManagement(entity, params, context) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
367 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
368 |
context['evaluation_list'] = self._getEvaluationLists(request, params, |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
369 |
entity) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
370 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
371 |
if request.POST: |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
372 |
return self.managePost(request, template, context, params, entity, |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
373 |
**kwargs) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
374 |
else: #request.GET |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
375 |
return self.manageGet(request, template, context, params, entity, |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
376 |
**kwargs) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
377 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
378 |
def _enableMentorManagement(self, entity, params, context): |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
379 |
"""Sets the data required to manage mentors for a StudentProject. |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
380 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
381 |
Args: |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
382 |
entity: StudentProject entity to manage |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
383 |
params: params dict for the manage view |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
384 |
context: context for the manage view |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
385 |
""" |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
386 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
387 |
# get all mentors for this organization |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
388 |
fields = {'scope': entity.scope, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
389 |
'status': 'active'} |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
390 |
mentors = mentor_logic.logic.getForFields(fields) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
391 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
392 |
choices = [(mentor.link_id,'%s (%s)' %(mentor.name(), mentor.link_id)) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
393 |
for mentor in mentors] |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
394 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
395 |
# create the form that org admins will use to reassign a mentor |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
396 |
dynafields = [ |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
397 |
{'name': 'mentor_id', |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
398 |
'base': forms.ChoiceField, |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
399 |
'label': 'Primary Mentor', |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
400 |
'required': True, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
401 |
'passthrough': ['required', 'choices', 'label'], |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
402 |
'choices': choices, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
403 |
},] |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
404 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
405 |
dynaproperties = params_helper.getDynaFields(dynafields) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
406 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
407 |
mentor_edit_form = dynaform.newDynaForm( |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
408 |
dynabase = params['dynabase'], |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
409 |
dynaproperties = dynaproperties, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
410 |
) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
411 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
412 |
params['mentor_edit_form'] = mentor_edit_form |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
413 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
414 |
additional_mentors = entity.additional_mentors |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
415 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
416 |
# we want to show the names of the additional mentors in the context |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
417 |
# therefore they need to be resolved to entities first |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
418 |
additional_mentors_context = [] |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
419 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
420 |
for mentor_key in additional_mentors: |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
421 |
mentor_entity = mentor_logic.logic.getFromKeyName( |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
422 |
mentor_key.id_or_name()) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
423 |
additional_mentors_context.append(mentor_entity) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
424 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
425 |
context['additional_mentors'] = additional_mentors_context |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
426 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
427 |
# all mentors who are not already an additional mentor or |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
428 |
# the primary mentor are allowed to become an additional mentor |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
429 |
possible_additional_mentors = [m for m in mentors if |
2281
a702d92a57a6
Style fixes in app.soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2280
diff
changeset
|
430 |
(m.key() not in additional_mentors) |
a702d92a57a6
Style fixes in app.soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2280
diff
changeset
|
431 |
and (m.key() != entity.mentor.key())] |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
432 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
433 |
# create the information to be shown on the additional mentor form |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
434 |
additional_mentor_choices = [ |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
435 |
(mentor.link_id,'%s (%s)' %(mentor.name(), mentor.link_id)) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
436 |
for mentor in possible_additional_mentors] |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
437 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
438 |
dynafields = [ |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
439 |
{'name': 'mentor_id', |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
440 |
'base': forms.ChoiceField, |
2279
e31414fd3b2a
Changed Additional Mentors to Co-Mentors in the manage view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2278
diff
changeset
|
441 |
'label': 'Co-Mentor', |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
442 |
'required': True, |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
443 |
'passthrough': ['required', 'choices', 'label'], |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
444 |
'choices': additional_mentor_choices, |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
445 |
},] |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
446 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
447 |
dynaproperties = params_helper.getDynaFields(dynafields) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
448 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
449 |
additional_mentor_form = dynaform.newDynaForm( |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
450 |
dynabase = params['dynabase'], |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
451 |
dynaproperties = dynaproperties, |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
452 |
) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
453 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
454 |
params['additional_mentor_form'] = additional_mentor_form |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
455 |
|
2688
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
456 |
def _getEvaluationLists(self, request, params, entity): |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
457 |
"""Returns List Object containing the list to be shown on the Student |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
458 |
Project's manage page. |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
459 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
460 |
This list contains all Surveys that have at least one record and will also |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
461 |
contain information about the presence (or absence) of a accompanying |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
462 |
record for the given Student Project. |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
463 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
464 |
Args: |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
465 |
request: Django HTTP Request Object |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
466 |
params: the params dict for this View |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
467 |
entity: a StudentProject entity for which the Surveys(Records) should be |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
468 |
retrieved |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
469 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
470 |
Returns: |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
471 |
A List Object as specified by this method. |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
472 |
""" |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
473 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
474 |
from soc.views.helper import list_info |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
475 |
from soc.views.models.grading_project_survey import view as \ |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
476 |
grading_survey_view |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
477 |
from soc.views.models.project_survey import view as project_survey_view |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
478 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
479 |
fields = {'scope_path': entity.program.key().id_or_name()} |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
480 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
481 |
# get the GradingProjectSurvey list |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
482 |
gps_params = grading_survey_view.getParams().copy() |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
483 |
gps_params['list_key_order'] = None |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
484 |
gps_params['list_heading'] = gps_params['manage_student_project_heading'] |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
485 |
gps_params['list_row'] = gps_params['manage_student_project_row'] |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
486 |
|
2693
7bda04a2b6c3
Style fixes in StudentProject View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2691
diff
changeset
|
487 |
# list all surveys for this Project's Program |
2688
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
488 |
fields['scope_path'] = entity.program.key().id_or_name() |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
489 |
gps_params['list_description'] = \ |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
490 |
'List of all Mentor Evaluations for this Project' |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
491 |
gps_params['list_action'] = None |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
492 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
493 |
gps_list = lists.getListContent( |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
494 |
request, gps_params, fields, idx=0) |
2730
d1cfed8da027
Redone the list_info function for the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2717
diff
changeset
|
495 |
list_info.setProjectSurveyInfoForProject(gps_list, entity, gps_params) |
2688
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
496 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
497 |
# get the ProjectSurvey list |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
498 |
ps_params = project_survey_view.getParams().copy() |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
499 |
ps_params['list_key_order'] = None |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
500 |
ps_params['list_heading'] = ps_params['manage_student_project_heading'] |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
501 |
ps_params['list_row'] = ps_params['manage_student_project_row'] |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
502 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
503 |
ps_params['list_description'] = \ |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
504 |
'List of all Student Evaluations for this Project' |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
505 |
ps_params['list_action'] = None |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
506 |
|
2693
7bda04a2b6c3
Style fixes in StudentProject View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2691
diff
changeset
|
507 |
# list all surveys for this Project's Program |
2688
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
508 |
fields['scope_path'] = entity.program.key().id_or_name() |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
509 |
ps_list = lists.getListContent( |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
510 |
request, ps_params, fields, idx=1) |
2730
d1cfed8da027
Redone the list_info function for the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2717
diff
changeset
|
511 |
list_info.setProjectSurveyInfoForProject(ps_list, entity, ps_params) |
2688
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
512 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
513 |
# store both lists in the content |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
514 |
content = [gps_list, ps_list] |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
515 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
516 |
for list in content: |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
517 |
# remove all the surveys that have no records attached |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
518 |
list['data'] = [i for i in list['data'] if |
2689
18d8486fd411
Renamed hasAtLeastOneRecord to hasRecord.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2688
diff
changeset
|
519 |
list['logic'].hasRecord(i)] |
2688
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
520 |
|
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
521 |
# return the List Object with the filtered list content |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
522 |
return soc.logic.lists.Lists(content) |
dfe0439a0711
Added list of Surveys to the Project's manage page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2685
diff
changeset
|
523 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
524 |
def manageGet(self, request, template, context, params, entity, **kwargs): |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
525 |
"""Handles the GET request for the project's manage page. |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
526 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
527 |
Args: |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
528 |
template: the template used for this view |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
529 |
entity: the student project entity |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
530 |
rest: see base.View.public() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
531 |
""" |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
532 |
|
2743
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
533 |
get_dict = request.GET |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
534 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
535 |
if 'remove' in get_dict and entity.status == 'accepted': |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
536 |
# get the mentor to remove |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
537 |
fields = {'link_id': get_dict['remove'], |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
538 |
'scope': entity.scope} |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
539 |
mentor = mentor_logic.logic.getForFields(fields, unique=True) |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
540 |
|
2743
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
541 |
additional_mentors = entity.additional_mentors |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
542 |
# pylint: disable- msg=E1103 |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
543 |
if additional_mentors and mentor.key() in additional_mentors: |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
544 |
# remove the mentor from the additional mentors list |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
545 |
additional_mentors.remove(mentor.key()) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
546 |
fields = {'additional_mentors': additional_mentors} |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
547 |
project_logic.updateEntityProperties(entity, fields) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
548 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
549 |
# redirect to the same page without GET arguments |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
550 |
redirect = request.path |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
551 |
return http.HttpResponseRedirect(redirect) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
552 |
|
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
553 |
if entity.status == 'accepted': |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
554 |
# populate forms with the current mentors set |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
555 |
initial = {'mentor_id': entity.mentor.link_id} |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
556 |
context['mentor_edit_form'] = params['mentor_edit_form'](initial=initial) |
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
557 |
context['additional_mentor_form'] = params['additional_mentor_form']() |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
558 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
559 |
return responses.respond(request, template, context) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
560 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
561 |
def managePost(self, request, template, context, params, entity, **kwargs): |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
562 |
"""Handles the POST request for the project's manage page. |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
563 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
564 |
Args: |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
565 |
template: the template used for this view |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
566 |
entity: the student project entity |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
567 |
rest: see base.View.public() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
568 |
""" |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
569 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
570 |
post_dict = request.POST |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
571 |
|
2743
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
572 |
if 'set_mentor' in post_dict and entity.status == 'accepted': |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
573 |
form = params['mentor_edit_form'](post_dict) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
574 |
return self._manageSetMentor(request, template, context, params, entity, |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
575 |
form) |
2743
b9a146acb9bb
Enable the project management page to be visited for project in other statusses.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2730
diff
changeset
|
576 |
elif 'add_additional_mentor' in post_dict and entity.status == 'accepted': |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
577 |
form = params['additional_mentor_form'](post_dict) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
578 |
return self._manageAddAdditionalMentor(request, template, context, |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
579 |
params, entity, form) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
580 |
else: |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
581 |
# unexpected error return the normal page |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
582 |
logging.warning('Unexpected POST data found') |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
583 |
return self.manageGet(request, template, context, params, entity) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
584 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
585 |
def _manageSetMentor(self, request, template, context, params, entity, form): |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
586 |
"""Handles the POST request for changing a Projects's mentor. |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
587 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
588 |
Args: |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
589 |
template: the template used for this view |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
590 |
entity: the student project entity |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
591 |
form: instance of the form used to set the mentor |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
592 |
rest: see base.View.public() |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
593 |
""" |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
594 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
595 |
if not form.is_valid(): |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
596 |
context['mentor_edit_form'] = form |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
597 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
598 |
# add an a fresh additional mentors form |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
599 |
context['additional_mentor_form'] = params['additional_mentor_form']() |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
600 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
601 |
return responses.respond(request, template, context) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
602 |
|
2117
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
603 |
_, fields = forms_helper.collectCleanedFields(form) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
604 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
605 |
# get the mentor from the form |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
606 |
fields = {'link_id': fields['mentor_id'], |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
607 |
'scope': entity.scope, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
608 |
'status': 'active'} |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
609 |
mentor = mentor_logic.logic.getForFields(fields, unique=True) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
610 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
611 |
# update the project with the assigned mentor |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
612 |
fields = {'mentor': mentor} |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
613 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
614 |
additional_mentors = entity.additional_mentors |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
615 |
|
2360
e389d26949db
Style and pylint fixes in Melange modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2330
diff
changeset
|
616 |
# pylint: disable-msg=E1103 |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
617 |
if additional_mentors and mentor.key() in additional_mentors: |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
618 |
# remove the mentor that is now becoming the primary mentor |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
619 |
additional_mentors.remove(mentor.key()) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
620 |
fields['additional_mentors'] = additional_mentors |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
621 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
622 |
# update the project with the new mentor and possible |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
623 |
# new set of additional mentors |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
624 |
project_logic.updateEntityProperties(entity, fields) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
625 |
|
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
626 |
# redirect to the same page |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
627 |
redirect = request.path |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
628 |
return http.HttpResponseRedirect(redirect) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
629 |
|
2281
a702d92a57a6
Style fixes in app.soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2280
diff
changeset
|
630 |
def _manageAddAdditionalMentor(self, request, template, |
a702d92a57a6
Style fixes in app.soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2280
diff
changeset
|
631 |
context, params, entity, form): |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
632 |
"""Handles the POST request for changing a Projects's additional mentors. |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
633 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
634 |
Args: |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
635 |
template: the template used for this view |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
636 |
entity: the student project entity |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
637 |
form: instance of the form used to add an additional mentor |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
638 |
rest: see base.View.public() |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
639 |
""" |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
640 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
641 |
if not form.is_valid(): |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
642 |
context['additional_mentor_form'] = form |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
643 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
644 |
# add a fresh edit mentor form |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
645 |
initial = {'mentor_id': entity.mentor.link_id} |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
646 |
context['mentor_edit_form'] = params['mentor_edit_form'](initial=initial) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
647 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
648 |
return responses.respond(request, template, context) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
649 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
650 |
_, fields = forms_helper.collectCleanedFields(form) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
651 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
652 |
# get the mentor from the form |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
653 |
fields = {'link_id': fields['mentor_id'], |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
654 |
'scope': entity.scope, |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
655 |
'status': 'active'} |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
656 |
mentor = mentor_logic.logic.getForFields(fields, unique=True) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
657 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
658 |
# add this mentor to the additional mentors |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
659 |
if not entity.additional_mentors: |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
660 |
additional_mentors = [mentor.key()] |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
661 |
else: |
2640
da8aa1ff6943
Fixed an error occuring when assigning more then one secondary mentors.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2637
diff
changeset
|
662 |
additional_mentors = entity.additional_mentors |
da8aa1ff6943
Fixed an error occuring when assigning more then one secondary mentors.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2637
diff
changeset
|
663 |
additional_mentors.append(mentor.key()) |
2278
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
664 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
665 |
fields = {'additional_mentors': additional_mentors} |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
666 |
project_logic.updateEntityProperties(entity, fields) |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
667 |
|
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
668 |
# redirect to the same page |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
669 |
redirect = request.path |
c4d40ab98f71
Added functionality to set additional mentors for a Student Project.
Lennard de Rijk
parents:
2241
diff
changeset
|
670 |
return http.HttpResponseRedirect(redirect) |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
671 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
672 |
@decorators.merge_params |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
673 |
@decorators.check_access |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
674 |
def manageOverview(self, request, access_type, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
675 |
page_name=None, params=None, **kwargs): |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
676 |
"""View that allows Organization Admins to see an overview of |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
677 |
their Organization's Student Projects. |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
678 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
679 |
For params see base.View().public() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
680 |
""" |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
681 |
|
2685
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
682 |
from soc.views.helper import list_info |
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
683 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
684 |
# make sure the organization exists |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
685 |
org_entity = org_logic.getFromKeyNameOr404(kwargs['scope_path']) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
686 |
fields = {'scope': org_entity} |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
687 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
688 |
# get the context for this webpage |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
689 |
context = responses.getUniversalContext(request) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
690 |
responses.useJavaScript(context, params['js_uses_all']) |
2117
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
691 |
context['page_name'] = '%s %s' % (page_name, org_entity.name) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
692 |
|
2856
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
693 |
prefetch = ['student', 'mentor'] |
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
694 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
695 |
list_params = params.copy() |
2685
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
696 |
list_params['list_heading'] = params['manage_overview_heading'] |
506cda0463e8
Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2640
diff
changeset
|
697 |
list_params['list_row'] = params['manage_overview_row'] |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
698 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
699 |
#list all active projects |
2573
f09f317769c4
Changed the StudentProject model to handle a dynamic amount of GradeRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
700 |
fields['status'] = 'accepted' |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
701 |
active_params = list_params.copy() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
702 |
active_params['list_description'] = \ |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
703 |
'List of all active %(name_plural)s' % list_params |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
704 |
active_params['list_action'] = (redirects.getManageRedirect, list_params) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
705 |
|
2856
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
706 |
active_list = lists.getListContent(request, active_params, fields, idx=0, |
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
707 |
prefetch=prefetch) |
2691
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
708 |
# set the needed info |
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
709 |
active_list = list_info.setStudentProjectSurveyInfo(active_list, |
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
710 |
org_entity.scope) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
711 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
712 |
# list all failed projects |
2573
f09f317769c4
Changed the StudentProject model to handle a dynamic amount of GradeRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
713 |
fields['status'] = 'failed' |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
714 |
failed_params = list_params.copy() |
2746
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
715 |
failed_params['list_description'] = ('List of all %(name_plural)s who ' |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
716 |
'failed the program.') % list_params |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
717 |
failed_params['list_action'] = (redirects.getManageRedirect, list_params) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
718 |
|
2856
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
719 |
failed_list = lists.getListContent(request, failed_params, fields, idx=1, |
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
720 |
need_content=True, prefetch=prefetch) |
2691
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
721 |
# set the needed info |
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
722 |
failed_list = list_info.setStudentProjectSurveyInfo(failed_list, |
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
723 |
org_entity.scope) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
724 |
|
2693
7bda04a2b6c3
Style fixes in StudentProject View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2691
diff
changeset
|
725 |
# list all completed projects |
2573
f09f317769c4
Changed the StudentProject model to handle a dynamic amount of GradeRecords.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
726 |
fields['status'] = 'completed' |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
727 |
completed_params = list_params.copy() |
2746
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
728 |
completed_params['list_description'] = ( |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
729 |
'List of %(name_plural)s that have successfully completed the ' |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
730 |
'program.' % list_params) |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
731 |
completed_params['list_action'] = (redirects.getManageRedirect, list_params) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
732 |
|
2856
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
733 |
completed_list = lists.getListContent(request, completed_params, fields, |
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
734 |
idx=2, need_content=True, |
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
735 |
prefetch=prefetch) |
2691
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
736 |
# set the needed info |
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
737 |
completed_list = list_info.setStudentProjectSurveyInfo(completed_list, |
f8e0a007d99b
Pre-storing the information for setStudentProjectSurveyInfo.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2689
diff
changeset
|
738 |
org_entity.scope) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
739 |
|
2746
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
740 |
# list all withdrawn projects |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
741 |
fields['status'] = 'withdrawn' |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
742 |
withdrawn_params = list_params.copy() |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
743 |
withdrawn_params['list_description'] = ( |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
744 |
'List of %(name_plural)s that have withdrawn from the program.' %( |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
745 |
list_params)) |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
746 |
withdrawn_params['list_action'] = (redirects.getManageRedirect, list_params) |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
747 |
|
2856
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
748 |
withdrawn_list = lists.getListContent(request, withdrawn_params, fields, |
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
749 |
idx=3, need_content=True, |
f446e019825c
Prefetch referenced fields in project listing
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2746
diff
changeset
|
750 |
prefetch=prefetch) |
2746
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
751 |
# set the needed info |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
752 |
withdrawn_list = list_info.setStudentProjectSurveyInfo(withdrawn_list, |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
753 |
org_entity.scope) |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
754 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
755 |
# always show the list with active projects |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
756 |
content = [active_list] |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
757 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
758 |
if failed_list != None: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
759 |
# do not show empty failed list |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
760 |
content.append(failed_list) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
761 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
762 |
if completed_list != None: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
763 |
# do not show empty completed list |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
764 |
content.append(completed_list) |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
765 |
|
2746
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
766 |
if withdrawn_list != None: |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
767 |
# do not show empty withdrawn list |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
768 |
content.append(withdrawn_list) |
ca3b1a86bce8
Redirect to the manage page for failed, completed and withdrawn projects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2743
diff
changeset
|
769 |
|
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
770 |
# call the _list method from base to display the list |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
771 |
return self._list(request, list_params, content, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
772 |
context['page_name'], context) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
773 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
774 |
@decorators.merge_params |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
775 |
@decorators.check_access |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
776 |
def stEdit(self, request, access_type, |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
777 |
page_name=None, params=None, **kwargs): |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
778 |
"""View that allows students to edit information about their project. |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
779 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
780 |
For params see base.View().public() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
781 |
""" |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
782 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
783 |
try: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
784 |
entity = self._logic.getFromKeyFieldsOr404(kwargs) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
785 |
except out_of_band.Error, error: |
2117
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
786 |
return responses.errorResponse( |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
787 |
error, request, template=params['error_public']) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
788 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
789 |
# get the context for this webpage |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
790 |
context = responses.getUniversalContext(request) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
791 |
responses.useJavaScript(context, params['js_uses_all']) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
792 |
context['page_name'] = page_name |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
793 |
# cancel should go to the public view |
2330
068540d91bde
Now clicking cancel button returns user to previous page. Fixes issue 569.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2281
diff
changeset
|
794 |
params['cancel_redirect'] = redirects.getPublicRedirect(entity, params) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
795 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
796 |
if request.POST: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
797 |
return self.stEditPost(request, context, params, entity, **kwargs) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
798 |
else: #request.GET |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
799 |
return self.stEditGet(request, context, params, entity, **kwargs) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
800 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
801 |
def stEditGet(self, request, context, params, entity, **kwargs): |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
802 |
"""Handles the GET request for the student's edit page. |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
803 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
804 |
Args: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
805 |
entity: the student project entity |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
806 |
rest: see base.View.public() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
807 |
""" |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
808 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
809 |
# populate form with the existing entity |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
810 |
form = params['student_edit_form'](instance=entity) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
811 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
812 |
return self._constructResponse(request, entity, context, form, params) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
813 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
814 |
def stEditPost(self, request, context, params, entity, **kwargs): |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
815 |
"""Handles the POST request for the student's edit page. |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
816 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
817 |
Args: |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
818 |
entity: the student project entity |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
819 |
rest: see base.View.public() |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
820 |
""" |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
821 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
822 |
form = params['student_edit_form'](request.POST) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
823 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
824 |
if not form.is_valid(): |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
825 |
return self._constructResponse(request, entity, context, form, params) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
826 |
|
2117
f1a1a75cdb00
Add missing imports, remove unsused imports, fix too long lines and some other style fixes in soc.views.models.student_project module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2115
diff
changeset
|
827 |
_, fields = forms_helper.collectCleanedFields(form) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
828 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
829 |
project_logic.updateEntityProperties(entity, fields) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
830 |
|
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
831 |
return self.stEditGet(request, context, params, entity, **kwargs) |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
832 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
833 |
|
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
834 |
view = View() |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
835 |
|
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
836 |
accept_project = decorators.view(view.acceptProject) |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
837 |
admin = decorators.view(view.admin) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
838 |
create = decorators.view(view.create) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
839 |
delete = decorators.view(view.delete) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
840 |
edit = decorators.view(view.edit) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
841 |
list = decorators.view(view.list) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
842 |
manage = decorators.view(view.manage) |
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
843 |
manage_overview = decorators.view(view.manageOverview) |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
844 |
public = decorators.view(view.public) |
2115
fafd021def7e
Major update to the views concerning StudentProjects.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
845 |
st_edit = decorators.view(view.stEdit) |
1936
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
846 |
export = decorators.view(view.export) |
ea886e0aedc4
Added basic student project view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
847 |
pick = decorators.view(view.pick) |
2705
0b38d59d958f
Allow hosts to withdraw student projects
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2693
diff
changeset
|
848 |
withdraw = decorators.view(view.withdraw) |
2711
4df8c11c36cb
addressed comments by Lennard
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2707
diff
changeset
|
849 |
withdraw_project = decorators.view(view.withdrawProject) |