author | Lennard de Rijk <ljvderijk@gmail.com> |
Sat, 11 Jul 2009 23:29:22 +0200 | |
changeset 2598 | 59ebf718c6a4 |
parent 2177 | e2c193e1f631 |
child 2667 | 260aaea36e49 |
permissions | -rw-r--r-- |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
1307
091a21cf3627
Update the copyright notice for 2009.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1283
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Organization Admins. |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>' |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
22 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
] |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
from django import forms |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
27 |
from django.utils.translation import ugettext |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
28 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
29 |
from soc.logic import dicts |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
30 |
from soc.logic.models import organization as org_logic |
1163
d8c50be19232
Cleaned up access.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1128
diff
changeset
|
31 |
from soc.logic.models import org_admin as org_admin_logic |
1313
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
32 |
from soc.logic.models import org_app as org_app_logic |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
from soc.views.helper import access |
1583 | 34 |
from soc.views.helper import decorators |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
35 |
from soc.views.helper import dynaform |
1726
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
36 |
from soc.views.helper import redirects |
1461
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
37 |
from soc.views.helper import params as params_helper |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
38 |
from soc.views.helper import widgets |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
39 |
from soc.views.models import organization as org_view |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
from soc.views.models import role |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
import soc.logic.models.org_admin |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
44 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
45 |
class View(role.View): |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
46 |
"""View methods for the Organization Admin model. |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
47 |
""" |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
48 |
|
1313
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
49 |
DEF_ALREADY_AGREED_MSG = ugettext( |
1351
8f66731fe62d
Change the message shown when org admin already agreed to agreement when creating org application.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
50 |
"You have already accepted this agreement when submitting " |
8f66731fe62d
Change the message shown when org admin already agreed to agreement when creating org application.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
51 |
"the organization application.") |
1313
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
52 |
|
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
def __init__(self, params=None): |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
54 |
"""Defines the fields and methods required for the base View class |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
to provide the user with list, public, create, edit and delete views. |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
56 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
Params: |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
params: a dict with params for this View |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
59 |
""" |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
60 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
61 |
rights = access.Checker(params) |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
62 |
rights['create'] = ['checkIsDeveloper'] |
2018
c584eb2f57db
Added missing access checks to various roles.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1955
diff
changeset
|
63 |
rights['edit'] = [('checkHasActiveRoleForScope', org_admin_logic.logic), |
2020
df3552deba66
Clarified docstring in access.py and changed edit access checks for role views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2018
diff
changeset
|
64 |
('checkIsMyEntity', [org_admin_logic.logic, 'user', True])] |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
65 |
rights['delete'] = ['checkIsDeveloper'] |
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1461
diff
changeset
|
66 |
rights['invite'] = [('checkHasActiveRoleForScope', |
1386
0c205ce4e27d
Org admins can now send out invitations and users can now request to become a mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1384
diff
changeset
|
67 |
org_admin_logic.logic)] |
1377
101759701e51
Students can not become a mentor or org_admin in the same program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1351
diff
changeset
|
68 |
rights['accept_invite'] = [('checkCanCreateFromRequest', 'org_admin'), |
101759701e51
Students can not become a mentor or org_admin in the same program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1351
diff
changeset
|
69 |
'checkIsNotStudentForProgramOfOrg'] |
1386
0c205ce4e27d
Org admins can now send out invitations and users can now request to become a mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1384
diff
changeset
|
70 |
rights['process_request'] = [ |
0c205ce4e27d
Org admins can now send out invitations and users can now request to become a mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1384
diff
changeset
|
71 |
('checkHasActiveRoleForScope', org_admin_logic.logic), |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
72 |
('checkCanProcessRequest', 'org_admin')] |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
73 |
rights['manage'] = [ |
1386
0c205ce4e27d
Org admins can now send out invitations and users can now request to become a mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1384
diff
changeset
|
74 |
('checkIsAllowedToManageRole', [org_admin_logic.logic, |
0c205ce4e27d
Org admins can now send out invitations and users can now request to become a mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1384
diff
changeset
|
75 |
org_admin_logic.logic])] |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
76 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
77 |
new_params = {} |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
78 |
new_params['logic'] = soc.logic.models.org_admin.logic |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
79 |
new_params['group_logic'] = org_logic.logic |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
80 |
new_params['group_view'] = org_view.view |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
81 |
new_params['rights'] = rights |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
82 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
83 |
new_params['scope_view'] = org_view |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
84 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
85 |
new_params['name'] = "Organization Admin" |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
86 |
new_params['module_name'] = "org_admin" |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
87 |
new_params['sidebar_grouping'] = 'Organizations' |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
88 |
|
1387
857e6cc8ebc1
Added required program property to org_admin and mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1386
diff
changeset
|
89 |
new_params['extra_dynaexclude'] = ['agreed_to_tos', 'program'] |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
90 |
|
1461
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
91 |
new_params['create_dynafields'] = [ |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
92 |
{'name': 'scope_path', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
93 |
'base': forms.fields.CharField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
94 |
'widget': forms.HiddenInput, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
95 |
'required': True, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
96 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
97 |
{'name': 'admin_agreement', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
98 |
'base': forms.fields.CharField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
99 |
'required': False, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
100 |
'widget': widgets.AgreementField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
101 |
'group': ugettext("5. Terms of Service"), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
102 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
103 |
{'name': 'agreed_to_admin_agreement', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
104 |
'base': forms.fields.BooleanField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
105 |
'initial': False, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
106 |
'required':True, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
107 |
'label': ugettext('I agree to the Admin Agreement'), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
108 |
'group': ugettext("5. Terms of Service"), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
109 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
110 |
] |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
111 |
|
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
112 |
new_params['allow_invites'] = True |
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:
1377
diff
changeset
|
113 |
new_params['show_in_roles_overview'] = True |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
114 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
115 |
params = dicts.merge(params, new_params) |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
116 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
117 |
super(View, self).__init__(params=params) |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
118 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
119 |
# register the role with the group_view |
2177
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2020
diff
changeset
|
120 |
self._params['group_view'].registerRole(self._params['module_name'], self) |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
121 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
122 |
# create and store the special form for invited users |
1461
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
123 |
dynafields = [ |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
124 |
{'name': 'link_id', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
125 |
'base': forms.CharField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
126 |
'widget': widgets.ReadOnlyInput(), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
127 |
'required': False, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
128 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
129 |
{'name': 'admin_agreement', |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
130 |
'base': forms.fields.Field, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
131 |
'required': False, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
132 |
'widget': widgets.AgreementField, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
133 |
'group': ugettext("5. Terms of Service"), |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
134 |
}, |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
135 |
] |
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
136 |
|
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
137 |
dynaproperties = params_helper.getDynaFields(dynafields) |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
138 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
139 |
invited_create_form = dynaform.extendDynaForm( |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
140 |
dynaform = self._params['create_form'], |
1461
92c5a390739a
Convert student and org_admin to dynafield
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
141 |
dynaproperties = dynaproperties) |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
142 |
|
2177
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2020
diff
changeset
|
143 |
self._params['invited_create_form'] = invited_create_form |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
144 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
145 |
def _editPost(self, request, entity, fields): |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
146 |
"""See base.View._editPost(). |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
147 |
""" |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
148 |
|
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
149 |
if not entity: |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
150 |
fields['user'] = fields['link_id'] |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
151 |
fields['link_id'] = fields['user'].link_id |
1663
032210fcb952
Fix the bug where undefined variable was used in _editPost method of soc.view.models.org_admin module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1584
diff
changeset
|
152 |
group_logic = self._params['group_logic'] |
1387
857e6cc8ebc1
Added required program property to org_admin and mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1386
diff
changeset
|
153 |
group_entity = group_logic.getFromKeyName(fields['scope_path']) |
857e6cc8ebc1
Added required program property to org_admin and mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1386
diff
changeset
|
154 |
fields['program'] = group_entity.scope |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
155 |
|
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
156 |
fields['agreed_to_tos'] = fields['agreed_to_admin_agreement'] |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
157 |
|
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
158 |
super(View, self)._editPost(request, entity, fields) |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
159 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
160 |
def _acceptInvitePost(self, fields, request, context, params, **kwargs): |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
161 |
"""Fills in the fields that were missing in the invited_created_form. |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
162 |
|
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
163 |
For params see base.View._acceptInvitePost() |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
164 |
""" |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
165 |
|
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
166 |
# fill in the appropriate fields that were missing in the form |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
167 |
fields['user'] = fields['link_id'] |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
168 |
fields['link_id'] = fields['user'].link_id |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
169 |
fields['agreed_to_tos'] = fields['agreed_to_admin_agreement'] |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
170 |
|
1387
857e6cc8ebc1
Added required program property to org_admin and mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1386
diff
changeset
|
171 |
group_logic = params['group_logic'] |
857e6cc8ebc1
Added required program property to org_admin and mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1386
diff
changeset
|
172 |
group_entity = group_logic.getFromKeyName(fields['scope_path']) |
857e6cc8ebc1
Added required program property to org_admin and mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1386
diff
changeset
|
173 |
fields['program'] = group_entity.scope |
857e6cc8ebc1
Added required program property to org_admin and mentor.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1386
diff
changeset
|
174 |
|
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
175 |
def _editGet(self, request, entity, form): |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
176 |
"""Sets the content of the agreed_to_tos_on field and replaces. |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
177 |
|
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
178 |
Also replaces the agreed_to_tos field with a hidden field when the ToS has been signed. |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
179 |
For params see base.View._editGet(). |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
180 |
""" |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
181 |
|
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
182 |
if entity.agreed_to_tos: |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
183 |
form.fields['agreed_to_admin_agreement'] = forms.fields.BooleanField( |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
184 |
widget=forms.HiddenInput, initial=entity.agreed_to_tos, |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
185 |
required=True) |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
186 |
|
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
187 |
super(View, self)._editGet(request, entity, form) |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
188 |
|
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
189 |
def _editContext(self, request, context): |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
190 |
"""See base.View._editContext. |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
191 |
""" |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
192 |
|
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
193 |
entity = context['entity'] |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
194 |
form = context['form'] |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
195 |
|
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
196 |
if 'scope_path' in form.initial: |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
197 |
scope_path = form.initial['scope_path'] |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
198 |
elif 'scope_path' in request.POST: |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
199 |
scope_path = request.POST['scope_path'] |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
200 |
else: |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
201 |
form.fields['admin_agreement'] = None |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
202 |
return |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
203 |
|
1313
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
204 |
org_app = org_app_logic.logic.getFromKeyName(scope_path) |
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
205 |
|
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
206 |
if not entity and org_app: |
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
207 |
if org_app.applicant.key() == context['user'].key(): |
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
208 |
form.fields['agreed_to_admin_agreement'] = forms.fields.BooleanField( |
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
209 |
widget=widgets.ReadOnlyInput, initial=True, required=True, |
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
210 |
help_text=self.DEF_ALREADY_AGREED_MSG) |
ec79c190f5ca
Force-check the 'agreed to admin agreement' field if applicable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
211 |
|
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
212 |
entity = org_logic.logic.getFromKeyName(scope_path) |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
213 |
|
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
214 |
if not (entity and entity.scope and entity.scope.org_admin_agreement): |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
215 |
return |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
216 |
|
1726
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
217 |
agreement = entity.scope.org_admin_agreement |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
218 |
|
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
219 |
content = agreement.content |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
220 |
params = {'url_name': 'document'} |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
221 |
|
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
222 |
widget = form.fields['admin_agreement'].widget |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
223 |
widget.text = content |
711c8dcab67e
Add a link to the full agreement text
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1663
diff
changeset
|
224 |
widget.url = redirects.getPublicRedirect(agreement, params) |
1128
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
225 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
226 |
|
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
227 |
view = View() |
18d0e10b02f7
Added a view and templates for the organization admin.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
228 |
|
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
229 |
accept_invite = decorators.view(view.acceptInvite) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
230 |
admin = decorators.view(view.admin) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
231 |
create = decorators.view(view.create) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
232 |
delete = decorators.view(view.delete) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
233 |
edit = decorators.view(view.edit) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
234 |
invite = decorators.view(view.invite) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
235 |
list = decorators.view(view.list) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
236 |
manage = decorators.view(view.manage) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
237 |
process_request = decorators.view(view.processRequest) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
238 |
public = decorators.view(view.public) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
239 |
export = decorators.view(view.export) |