author | Lennard de Rijk <ljvderijk@gmail.com> |
Tue, 17 Feb 2009 20:15:43 +0000 | |
changeset 1383 | 18383d2e5a5b |
parent 1349 | d05a9bf08c11 |
child 1430 | ff8cc6b15e6a |
permissions | -rw-r--r-- |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
2 |
# |
1307
091a21cf3627
Update the copyright notice for 2009.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1297
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
4 |
# |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
7 |
# You may obtain a copy of the License at |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
8 |
# |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
10 |
# |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
15 |
# limitations under the License. |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
16 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
17 |
"""Views for Organization App profiles. |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
18 |
""" |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
19 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
20 |
__authors__ = [ |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
22 |
] |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
23 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
24 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
25 |
from django import forms |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
26 |
from django.utils import simplejson |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
27 |
|
1205
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
28 |
from soc.logic import cleaning |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
29 |
from soc.logic import dicts |
1205
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
30 |
from soc.logic import models as model_logic |
1276
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
31 |
from soc.logic.models import program as program_logic |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
32 |
from soc.logic.models import org_app as org_app_logic |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
33 |
from soc.views.helper import access |
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
34 |
from soc.views.helper import decorators |
1185
fe25d98a24c3
Create org_application now shows select program view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1182
diff
changeset
|
35 |
from soc.views.helper import redirects |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
36 |
from soc.views.helper import responses |
1276
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
37 |
from soc.views.helper import widgets |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
38 |
from soc.views.models import group_app |
1185
fe25d98a24c3
Create org_application now shows select program view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1182
diff
changeset
|
39 |
from soc.views.models import program as program_view |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
40 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
41 |
import soc.logic.dicts |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
42 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
43 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
44 |
class View(group_app.View): |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
45 |
"""View methods for the Organization Application model. |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
46 |
""" |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
47 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
48 |
def __init__(self, params=None): |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
49 |
"""Defines the fields and methods required for the base View class |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
50 |
to provide the user with list, public, create, edit and delete views. |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
51 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
52 |
Params: |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
53 |
params: a dict with params for this View |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
54 |
""" |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
55 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
56 |
rights = access.Checker(params) |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
57 |
rights['create'] = ['checkIsDeveloper'] |
1200
e68fd70ba076
Added checkCanEditGroupApp to access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1185
diff
changeset
|
58 |
rights['delete'] = [('checkCanEditGroupApp', |
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
59 |
[org_app_logic.logic]), |
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
60 |
('checkIsActivePeriod', ['org_signup', 'scope_path'])] |
1200
e68fd70ba076
Added checkCanEditGroupApp to access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1185
diff
changeset
|
61 |
rights['edit'] = [('checkCanEditGroupApp', |
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
62 |
[org_app_logic.logic]), |
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
63 |
('checkIsActivePeriod', ['org_signup', 'scope_path'])] |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
64 |
rights['list'] = ['checkIsDeveloper'] |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1250
diff
changeset
|
65 |
rights['list_self'] = ['checkIsUser'] |
1200
e68fd70ba076
Added checkCanEditGroupApp to access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1185
diff
changeset
|
66 |
rights['public'] = [('checkCanEditGroupApp', |
e68fd70ba076
Added checkCanEditGroupApp to access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1185
diff
changeset
|
67 |
[org_app_logic.logic])] |
1250
b06e6e014658
Fixed access checkers for orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1246
diff
changeset
|
68 |
rights['review'] = ['checkIsHostForProgramInScope', |
1201
0a4c1af700a0
Added checkCanReviewGroupApp to acces.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1200
diff
changeset
|
69 |
('checkCanReviewGroupApp', [org_app_logic.logic])] |
1250
b06e6e014658
Fixed access checkers for orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1246
diff
changeset
|
70 |
rights['review_overview'] = ['checkIsHostForProgramInScope'] |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
71 |
rights['bulk_accept'] = ['checkIsHostForProgramInScope'] |
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
72 |
rights['apply'] = ['checkIsUser', |
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
73 |
('checkCanCreateOrgApp', ['org_signup'])] |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
74 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
75 |
new_params = {} |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
76 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
77 |
new_params['rights'] = rights |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
78 |
new_params['logic'] = org_app_logic.logic |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
79 |
|
1185
fe25d98a24c3
Create org_application now shows select program view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1182
diff
changeset
|
80 |
new_params['scope_view'] = program_view |
fe25d98a24c3
Create org_application now shows select program view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1182
diff
changeset
|
81 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
fe25d98a24c3
Create org_application now shows select program view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1182
diff
changeset
|
82 |
|
fe25d98a24c3
Create org_application now shows select program view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1182
diff
changeset
|
83 |
new_params['sidebar_grouping'] = 'Organizations' |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
84 |
|
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
85 |
patterns = [(r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$', |
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
86 |
'soc.views.models.%(module_name)s.create', |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
87 |
'Create an %(name_plural)s'), |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
88 |
(r'^%(url_name)s/(?P<access_type>bulk_accept)/%(scope)s$', |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
89 |
'soc.views.models.%(module_name)s.bulk_accept', |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
90 |
'Bulk Acceptation of %(name_plural)s'),] |
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
91 |
|
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
92 |
new_params['extra_django_patterns'] = patterns |
1276
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
93 |
new_params['extra_key_order'] = ['admin_agreement', |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
94 |
'agreed_to_admin_agreement'] |
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1205
diff
changeset
|
95 |
|
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
96 |
new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status', |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
97 |
'created_on', 'last_modified_on'] |
1205
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
98 |
|
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
99 |
new_params['create_extra_dynafields'] = { |
1205
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
100 |
'scope_path': forms.fields.CharField(widget=forms.HiddenInput, |
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
101 |
required=True), |
1276
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
102 |
'admin_agreement': forms.fields.Field(required=False, |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
103 |
widget=widgets.AgreementField), |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
104 |
'agreed_to_admin_agreement': forms.fields.BooleanField( |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
105 |
initial=False, required=True), |
1230
b1b1897e4df1
Cleanup in org_app and replace ReferenceProperty with LinkProperty
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1225
diff
changeset
|
106 |
'clean_ideas': cleaning.clean_url('ideas'), |
b1b1897e4df1
Cleanup in org_app and replace ReferenceProperty with LinkProperty
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1225
diff
changeset
|
107 |
'clean_contrib_template': cleaning.clean_url('contrib_template'), |
1205
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
108 |
'clean': cleaning.validate_new_group('link_id', 'scope_path', |
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
109 |
model_logic.organization, org_app_logic)} |
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
110 |
|
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
111 |
# get rid of the clean method |
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
112 |
new_params['edit_extra_dynafields'] = { |
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1201
diff
changeset
|
113 |
'clean': (lambda x: x.cleaned_data)} |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
114 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
115 |
new_params['name'] = "Organization Application" |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
116 |
new_params['name_plural'] = "Organization Applications" |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
117 |
new_params['name_short'] = "Org App" |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
118 |
new_params['url_name'] = "org_app" |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
119 |
new_params['group_url_name'] = 'org' |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
120 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
121 |
new_params['review_template'] = 'soc/org_app/review.html' |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
122 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
123 |
params = dicts.merge(params, new_params) |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
124 |
|
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
125 |
super(View, self).__init__(params=params) |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
126 |
|
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
127 |
@ decorators.merge_params |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
128 |
def reviewOverview(self, request, access_type, |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
129 |
page_name=None, params=None, **kwargs): |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
130 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
131 |
params['list_template'] = 'soc/org_app/review_overview.html' |
1296
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
132 |
context = {'bulk_accept_link': '/org_app/bulk_accept/%(scope_path)s' %( |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
133 |
kwargs)} |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
134 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
135 |
return super(View, self).reviewOverview(request, access_type, |
1296
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
136 |
page_name=page_name, params=params, context=context, **kwargs) |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
137 |
|
1276
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
138 |
def _editContext(self, request, context): |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
139 |
"""See base.View._editContext. |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
140 |
""" |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
141 |
|
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
142 |
entity = context['entity'] |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
143 |
form = context['form'] |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
144 |
|
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
145 |
if 'scope_path' in form.initial: |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
146 |
scope_path = form.initial['scope_path'] |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
147 |
elif 'scope_path' in request.POST: |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
148 |
# TODO: do this nicely |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
149 |
scope_path = request.POST['scope_path'] |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
150 |
else: |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
151 |
# TODO: is this always sufficient? |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
152 |
del form.fields['admin_agreement'] |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
153 |
return |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
154 |
|
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
155 |
entity = program_logic.logic.getFromKeyName(scope_path) |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
156 |
|
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
157 |
if not entity or not entity.org_admin_agreement: |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
158 |
return |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
159 |
|
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
160 |
content = entity.org_admin_agreement.content |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
161 |
|
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
162 |
form.fields['admin_agreement'].widget.text = content |
7f460f46a611
Initial implementation of a ToS requirement in org_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1255
diff
changeset
|
163 |
|
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
164 |
|
1296
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
165 |
def _review(self, request, params, app_entity, status, **kwargs): |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
166 |
"""Sends out an email if an org_app has been reviewed and accepted. |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
167 |
|
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
168 |
For params see group_app.View._review(). |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
169 |
""" |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
170 |
|
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
171 |
if status == 'accepted': |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
172 |
#TODO(ljvderijk) create the email template |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
173 |
pass |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
174 |
|
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
175 |
|
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
176 |
@decorators.merge_params |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
177 |
@decorators.check_access |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
178 |
def bulkAccept(self, request, access_type, |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
179 |
page_name=None, params=None, **kwargs): |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
180 |
"""Returns a HTTP Response containing JSON information needed |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
181 |
to bulk-accept orgs. |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
182 |
""" |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
183 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
184 |
program_entity = program_logic.logic.getFromKeyName(kwargs['scope_path']) |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
185 |
|
1349
d05a9bf08c11
Hopefully fix json caching issues in IE7.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
186 |
# get all pre-accepted organization applications for the given program |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
187 |
filter = {'scope' : program_entity, |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
188 |
'status' : 'pre-accepted'} |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
189 |
org_app_entities = org_app_logic.logic.getForFields(filter=filter) |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
190 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
191 |
# convert each application into a dictionary containing only the fields |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
192 |
# given by the dict_filter |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
193 |
dict_filter = ['link_id', 'name'] |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
194 |
org_apps = [dicts.filter(i.toDict(), dict_filter) for i in org_app_entities] |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
195 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
196 |
to_json = { |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
197 |
'program' : program_entity.name, |
1297
033fa805b361
Added number of applications and their type to the bulkaccept JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1296
diff
changeset
|
198 |
'nr_applications' : len(org_apps), |
033fa805b361
Added number of applications and their type to the bulkaccept JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1296
diff
changeset
|
199 |
'application_type' : params['name_plural'], |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
200 |
'applications': org_apps, |
1296
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
201 |
'link' : '/org_app/review/%s/(link_id)?status=accepted' %( |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1294
diff
changeset
|
202 |
program_entity.key().name()), |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
203 |
} |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
204 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
205 |
json = simplejson.dumps(to_json) |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
206 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
207 |
# use the standard JSON template to return our response |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
208 |
context = {'json': json} |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
209 |
template = 'soc/json.html' |
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
210 |
|
1331
e6fc2238bab0
Added no-cache headers to pick and bulk-accept views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1307
diff
changeset
|
211 |
response = responses.respond(request, template, context) |
1349
d05a9bf08c11
Hopefully fix json caching issues in IE7.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
212 |
|
d05a9bf08c11
Hopefully fix json caching issues in IE7.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
213 |
# if the browser supports HTTP/1.1 |
d05a9bf08c11
Hopefully fix json caching issues in IE7.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
214 |
# post-check and pre-check and no-store for IE7 |
d05a9bf08c11
Hopefully fix json caching issues in IE7.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
215 |
response['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' |
d05a9bf08c11
Hopefully fix json caching issues in IE7.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
216 |
# if the browser supports HTTP/1.0 |
1331
e6fc2238bab0
Added no-cache headers to pick and bulk-accept views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1307
diff
changeset
|
217 |
response['Pragma'] = 'no-cache' |
1349
d05a9bf08c11
Hopefully fix json caching issues in IE7.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
218 |
|
1331
e6fc2238bab0
Added no-cache headers to pick and bulk-accept views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1307
diff
changeset
|
219 |
return response |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
220 |
|
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
221 |
|
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
222 |
view = View() |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
223 |
|
1343
4ba39392c854
Hook up the admin view everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1331
diff
changeset
|
224 |
admin = view.admin |
1294
359987b7027d
Added bulk_accept view which returns a JSON object.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1276
diff
changeset
|
225 |
bulk_accept = view.bulkAccept |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
226 |
create = view.create |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
227 |
delete = view.delete |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
228 |
edit = view.edit |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
229 |
list = view.list |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1250
diff
changeset
|
230 |
list_self = view.listSelf |
1182
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
231 |
public = view.public |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
232 |
export = view.export |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
233 |
review = view.review |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
234 |
review_overview = view.reviewOverview |
5bea281505f4
Fixed EOL damage in org_app and access checks
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1151
diff
changeset
|
235 |