author | Mario Ferraro <fadinlight@gmail.com> |
Sun, 15 Nov 2009 22:12:20 +0100 | |
changeset 3093 | d1be59b6b627 |
parent 3079 | c491d96dce2c |
permissions | -rw-r--r-- |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Student. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
2927
ac4f93519855
Changed the Student Model cleaner to deal with the new Student properties.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2922
diff
changeset
|
21 |
'"Madhusudan.C.S." <madhusudancs@gmail.com>', |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>' |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
] |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
|
2371
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
26 |
import time |
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
27 |
|
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
28 |
from django import forms |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
29 |
from django.utils.translation import ugettext |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
30 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
from soc.logic import cleaning |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic import dicts |
2922
6e373954bbf6
Added GHOPStudent view and access checks.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2919
diff
changeset
|
33 |
from soc.logic.models import mentor as mentor_logic |
6e373954bbf6
Added GHOPStudent view and access checks.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2919
diff
changeset
|
34 |
from soc.logic.models import org_admin as org_admin_logic |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
35 |
from soc.logic.models import program as program_logic |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
36 |
from soc.logic.models import student as student_logic |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
from soc.logic.models import user as user_logic |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
38 |
from soc.views import out_of_band |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
39 |
from soc.views.helper import access |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
from soc.views.helper import decorators |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
from soc.views.helper import dynaform |
2186
eeb26c67cffa
Add missing responses import and replace usage of helper.responses with just responses in soc.views.models.student module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2158
diff
changeset
|
42 |
from soc.views.helper import responses |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
from soc.views.helper import redirects |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
44 |
from soc.views.helper import widgets |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
45 |
from soc.views.models import program as program_view |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
46 |
from soc.views.models import role |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
47 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
48 |
import soc.logic.models.student |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
49 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
class View(role.View): |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
52 |
"""View methods for the Student model. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
""" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
54 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
56 |
def __init__(self, params=None): |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
"""Defines the fields and methods required for the base View class |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
to provide the user with list, public, create, edit and delete views. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
59 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
60 |
Params: |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
61 |
params: a dict with params for this View |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
62 |
""" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
63 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
64 |
rights = access.Checker(params) |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
65 |
rights['create'] = ['checkIsDeveloper'] |
2919
cb677410c0f1
Using the new checkIsMyActiveRole check where necessary.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
66 |
rights['edit'] = [('checkIsMyActiveRole', student_logic.logic)] |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
67 |
rights['delete'] = ['checkIsDeveloper'] |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
68 |
rights['apply'] = [ |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
69 |
'checkIsUser', |
2781
8f6c0a5a7491
program_logic is passed as a parameter to three checkers than hard coding it.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2771
diff
changeset
|
70 |
('checkIsActivePeriod', |
8f6c0a5a7491
program_logic is passed as a parameter to three checkers than hard coding it.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2771
diff
changeset
|
71 |
['student_signup', 'scope_path', program_logic.logic]), |
2922
6e373954bbf6
Added GHOPStudent view and access checks.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2919
diff
changeset
|
72 |
('checkIsNotParticipatingInProgramInScope', [program_logic.logic, |
6e373954bbf6
Added GHOPStudent view and access checks.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2919
diff
changeset
|
73 |
student_logic.logic, org_admin_logic.logic, mentor_logic.logic]), |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
74 |
] |
2919
cb677410c0f1
Using the new checkIsMyActiveRole check where necessary.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
75 |
rights['manage'] = [('checkIsMyActiveRole', student_logic.logic)] |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
76 |
rights['list_projects'] = [ |
2239
9a47a64dcc08
Students can not list their own projects before the accepted students announced deadline.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2186
diff
changeset
|
77 |
('checkHasActiveRoleForScope', student_logic.logic), |
9a47a64dcc08
Students can not list their own projects before the accepted students announced deadline.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2186
diff
changeset
|
78 |
('checkIsAfterEvent', ['accepted_students_announced_deadline', |
2771
eb654b51053b
checkIsAfterEvent takes logic as argument instead of hard coded program logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2718
diff
changeset
|
79 |
'scope_path', program_logic.logic])] |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
80 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
81 |
new_params = {} |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
82 |
new_params['logic'] = soc.logic.models.student.logic |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
83 |
new_params['group_logic'] = program_logic.logic |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
84 |
new_params['group_view'] = program_view.view |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
85 |
new_params['rights'] = rights |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
86 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
87 |
new_params['scope_view'] = program_view |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
88 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
89 |
new_params['manage_redirect'] = redirects.getUserRolesRedirect |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
90 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
91 |
new_params['name'] = "Student" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
92 |
new_params['module_name'] = "student" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
93 |
new_params['sidebar_grouping'] = 'Students' |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
94 |
|
2927
ac4f93519855
Changed the Student Model cleaner to deal with the new Student properties.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2922
diff
changeset
|
95 |
new_params['create_template'] = 'soc/student/edit.html' |
ac4f93519855
Changed the Student Model cleaner to deal with the new Student properties.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2922
diff
changeset
|
96 |
new_params['edit_template'] = 'soc/student/edit.html' |
ac4f93519855
Changed the Student Model cleaner to deal with the new Student properties.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2922
diff
changeset
|
97 |
|
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
98 |
# add apply pattern |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
99 |
patterns = [(r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2781
diff
changeset
|
100 |
'%(module_package)s.%(module_name)s.apply', |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
101 |
'Become a %(name)s'), |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
102 |
(r'^%(url_name)s/(?P<access_type>list_projects)/%(scope)s$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2781
diff
changeset
|
103 |
'%(module_package)s.%(module_name)s.list_projects', |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
104 |
'List of my Student Projects'),] |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
105 |
|
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
106 |
new_params['extra_django_patterns'] = patterns |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
107 |
|
1383
18383d2e5a5b
Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1382
diff
changeset
|
108 |
new_params['extra_dynaexclude'] = ['agreed_to_tos', 'school'] |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
109 |
|
2371
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
110 |
current_year = time.gmtime().tm_year |
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
111 |
# the current year is not the minimum because a program could span |
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
112 |
# more than one year |
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
113 |
allowed_years = range(current_year-1, current_year+20) |
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
114 |
|
2929
04851beb824e
Moved the Student cleaner to the create form such that it is always used.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2927
diff
changeset
|
115 |
view_logic = params['logic'] if params else new_params['logic'] |
04851beb824e
Moved the Student cleaner to the create form such that it is always used.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2927
diff
changeset
|
116 |
|
1980
db7c98580008
Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1949
diff
changeset
|
117 |
new_params['create_extra_dynaproperties'] = { |
2371
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
118 |
'expected_graduation': forms.TypedChoiceField( |
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
119 |
choices=[(x,x) for x in allowed_years], |
805400745f57
Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2360
diff
changeset
|
120 |
coerce=lambda val: int(val) |
2927
ac4f93519855
Changed the Student Model cleaner to deal with the new Student properties.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2922
diff
changeset
|
121 |
), |
2929
04851beb824e
Moved the Student cleaner to the create form such that it is always used.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2927
diff
changeset
|
122 |
'clean': cleaning.validate_student( |
04851beb824e
Moved the Student cleaner to the create form such that it is always used.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2927
diff
changeset
|
123 |
'birth_date', 'school_type', 'major', 'degree', 'grade', |
04851beb824e
Moved the Student cleaner to the create form such that it is always used.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2927
diff
changeset
|
124 |
'scope_path', view_logic.getScopeLogic().logic), |
2927
ac4f93519855
Changed the Student Model cleaner to deal with the new Student properties.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2922
diff
changeset
|
125 |
} |
1980
db7c98580008
Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1949
diff
changeset
|
126 |
|
1461
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
127 |
new_params['create_dynafields'] = [ |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
128 |
{'name': 'scope_path', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
129 |
'base': forms.fields.CharField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
130 |
'widget': forms.HiddenInput, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
131 |
'required': True, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
132 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
133 |
{'name': 'student_agreement', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
134 |
'base': forms.fields.CharField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
135 |
'required': False, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
136 |
'widget': widgets.AgreementField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
137 |
'group': ugettext("5. Terms of Service"), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
138 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
139 |
{'name': 'agreed_to_student_agreement', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
140 |
'base': forms.fields.BooleanField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
141 |
'initial': False, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
142 |
'required':True, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
143 |
'label': ugettext('I agree to the Student Agreement'), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
144 |
'group': ugettext("5. Terms of Service"), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
145 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
146 |
] |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
147 |
|
1384
bb22ea156567
Role overview membership is now determined by setting show_in_roles_overview param to true in the view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1383
diff
changeset
|
148 |
new_params['show_in_roles_overview'] = True |
bb22ea156567
Role overview membership is now determined by setting show_in_roles_overview param to true in the view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1383
diff
changeset
|
149 |
|
3079
c491d96dce2c
Fixed 'Register as a student' link problem for GHOP program.
Daniel Hans <Daniel.M.Hans@gmail.com>
parents:
2929
diff
changeset
|
150 |
params = dicts.merge(params, new_params, sub_merge=True) |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
151 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
152 |
super(View, self).__init__(params=params) |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
153 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
154 |
# create and store the special form for users |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
155 |
updated_fields = { |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
156 |
'link_id': forms.CharField(widget=forms.HiddenInput, |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
157 |
required=True), |
2716
9921ac952f13
Added minimum age property to Program model.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
2656
diff
changeset
|
158 |
'clean_link_id': cleaning.clean_user_is_current('link_id'), |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
159 |
} |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
160 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
161 |
user_create_form = dynaform.extendDynaForm( |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
162 |
dynaform = self._params['create_form'], |
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1394
diff
changeset
|
163 |
dynaproperties = updated_fields) |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
164 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
165 |
self._params['user_create_form'] = user_create_form |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
166 |
|
1384
bb22ea156567
Role overview membership is now determined by setting show_in_roles_overview param to true in the view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1383
diff
changeset
|
167 |
|
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
168 |
@decorators.merge_params |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
169 |
@decorators.check_access |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
170 |
def apply(self, request, access_type, |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
171 |
page_name=None, params=None, **kwargs): |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
172 |
"""Handles student role creation for the current user. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
173 |
""" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
174 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
175 |
user_entity = user_logic.logic.getForCurrentAccount() |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
176 |
params['create_form'] = params['user_create_form'] |
2656
25210120d67b
Added validation to email fields where needed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2371
diff
changeset
|
177 |
|
2360
e389d26949db
Style and pylint fixes in Melange modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2239
diff
changeset
|
178 |
# pylint: disable-msg=E1103 |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
179 |
return self.create(request, access_type='unspecified', page_name=page_name, |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
180 |
params=params, link_id=user_entity.link_id, **kwargs) |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
181 |
|
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
182 |
@decorators.merge_params |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
183 |
@decorators.check_access |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
184 |
def listProjects(self, request, access_type, |
2157 | 185 |
page_name=None, params=None, **kwargs): |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
186 |
"""View that lists all of the current user's Student Projects for the |
2158 | 187 |
Program given as Scope. |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
188 |
""" |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
189 |
|
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
190 |
from soc.views.models import student_project as project_view |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
191 |
|
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
192 |
user_entity = user_logic.logic.getForCurrentAccount() |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
193 |
|
2360
e389d26949db
Style and pylint fixes in Melange modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2239
diff
changeset
|
194 |
# pylint: disable-msg=E1103 |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
195 |
fields = {'link_id': user_entity.link_id, |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
196 |
'scope_path': kwargs['scope_path']} |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
197 |
|
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
198 |
try: |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
199 |
student_entity = student_logic.logic.getFromKeyFieldsOr404(fields) |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
200 |
except out_of_band.Error, error: |
2186
eeb26c67cffa
Add missing responses import and replace usage of helper.responses with just responses in soc.views.models.student module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2158
diff
changeset
|
201 |
return responses.errorResponse( |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
202 |
error, request, template=params['error_public']) |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
203 |
|
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
204 |
# set the fields we need for the Student Project list |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
205 |
fields = {'student': student_entity} |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
206 |
|
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
207 |
list_params = project_view.view.getParams().copy() |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
208 |
list_params['list_description'] = ugettext( |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
209 |
'List of my Student Projects for %s') %(student_entity.scope.name) |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
210 |
list_params['list_action'] = (redirects.getStudentEditRedirect, list_params) |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
211 |
|
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
212 |
return project_view.view.list(request, access_type, page_name=page_name, |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
213 |
params=list_params, filter=fields) |
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
214 |
|
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
215 |
def _editPost(self, request, entity, fields): |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
216 |
"""See base.View._editPost(). |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
217 |
""" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
218 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
219 |
if not entity: |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
220 |
fields['user'] = fields['link_id'] |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
221 |
fields['link_id'] = fields['user'].link_id |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
222 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
223 |
fields['agreed_to_tos'] = fields['agreed_to_student_agreement'] |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
224 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
225 |
super(View, self)._editPost(request, entity, fields) |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
226 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
227 |
def _editGet(self, request, entity, form): |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
228 |
"""Sets the content of the agreed_to_tos_on field and replaces. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
229 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
230 |
Also replaces the agreed_to_tos field with a hidden field when the ToS has been signed. |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
231 |
For params see base.View._editGet(). |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
232 |
""" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
233 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
234 |
if entity.agreed_to_tos: |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
235 |
form.fields['agreed_to_student_agreement'] = forms.fields.BooleanField( |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
236 |
widget=forms.HiddenInput, initial=entity.agreed_to_tos, |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
237 |
required=True) |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
238 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
239 |
super(View, self)._editGet(request, entity, form) |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
240 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
241 |
def _editContext(self, request, context): |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
242 |
"""See base.View._editContext(). |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
243 |
""" |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
244 |
|
2076
1cd180cc56c9
Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2050
diff
changeset
|
245 |
# entity = context['entity'] |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
246 |
form = context['form'] |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
247 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
248 |
if 'scope_path' in form.initial: |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
249 |
scope_path = form.initial['scope_path'] |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
250 |
elif 'scope_path' in request.POST: |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
251 |
scope_path = request.POST['scope_path'] |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
252 |
else: |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
253 |
form.fields['student_agreement'] = None |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
254 |
return |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
255 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
256 |
program = program_logic.logic.getFromKeyName(scope_path) |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
257 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
258 |
if not (program and program.student_agreement): |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
259 |
return |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
260 |
|
1726
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
261 |
agreement = program.student_agreement |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
262 |
|
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
263 |
content = agreement.content |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
264 |
params = {'url_name': 'document'} |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
265 |
|
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
266 |
widget = form.fields['student_agreement'].widget |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
267 |
widget.text = content |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1724
diff
changeset
|
268 |
widget.url = redirects.getPublicRedirect(agreement, params) |
1379
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
269 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
270 |
|
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
271 |
view = View() |
e6341549300c
Added student view and accompanying templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
272 |
|
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
273 |
apply = decorators.view(view.apply) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
274 |
create = decorators.view(view.create) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
275 |
delete = decorators.view(view.delete) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
276 |
edit = decorators.view(view.edit) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
277 |
list = decorators.view(view.list) |
2154
a0a1594e58ae
Added listing of Student Projects for Students themselves.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2076
diff
changeset
|
278 |
list_projects = decorators.view(view.listProjects) |
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
279 |
manage = decorators.view(view.manage) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
280 |
public = decorators.view(view.public) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
281 |
export = decorators.view(view.export) |