author | Sverre Rabbelier <srabbelier@gmail.com> |
Mon, 09 Mar 2009 23:56:42 +0000 | |
changeset 1781 | f8e85447fbdf |
parent 1766 | 75531b82a4e2 |
child 1838 | 5a8a254af95b |
permissions | -rw-r--r-- |
682 | 1 |
#!/usr/bin/python2.5 |
2 |
# |
|
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
682 | 4 |
# |
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 |
# you may not use this file except in compliance with the License. |
|
7 |
# You may obtain a copy of the License at |
|
8 |
# |
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
|
10 |
# |
|
11 |
# Unless required by applicable law or agreed to in writing, software |
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 |
# See the License for the specific language governing permissions and |
|
15 |
# limitations under the License. |
|
16 |
||
17 |
"""Views for Organizations. |
|
18 |
""" |
|
19 |
||
20 |
__authors__ = [ |
|
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
21 |
'"Augie Fackler" <durin42@gmail.com>', |
682 | 22 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
23 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
682 | 24 |
] |
25 |
||
26 |
||
1685
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
27 |
import itertools |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
28 |
|
682 | 29 |
from django import forms |
1641
c2201decd4b4
Some style fixes, removal of unused imports and add ugettext where it was missing in soc.views.models.organization module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1605
diff
changeset
|
30 |
from django.utils.translation import ugettext |
682 | 31 |
|
690
14e9f484412c
Fix imports sorting in soc.views.models.organization.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
682
diff
changeset
|
32 |
from soc.logic import cleaning |
682 | 33 |
from soc.logic import dicts |
1344
d94410538f8e
Redirect to the admin view in listPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
34 |
from soc.logic import accounts |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
35 |
from soc.logic.models import mentor as mentor_logic |
1266
e8feadcbc47f
Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1264
diff
changeset
|
36 |
from soc.logic.models import organization as org_logic |
e8feadcbc47f
Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1264
diff
changeset
|
37 |
from soc.logic.models import org_admin as org_admin_logic |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
38 |
from soc.logic.models import org_app as org_app_logic |
1702 | 39 |
from soc.logic.models import program as program_logic |
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
40 |
from soc.logic.models import user as user_logic |
1567
b5589e656ed1
Member template in organization is now called Contributor Template.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1526
diff
changeset
|
41 |
from soc.views import helper |
1598
a55296590875
Fix a missing import reported in #melange.
Augie Fackler <durin42@gmail.com>
parents:
1596
diff
changeset
|
42 |
from soc.views import out_of_band |
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
43 |
from soc.views.helper import access |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
44 |
from soc.views.helper import decorators |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
45 |
from soc.views.helper import dynaform |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
46 |
from soc.views.helper import lists |
682 | 47 |
from soc.views.helper import redirects |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
48 |
from soc.views.helper import widgets |
682 | 49 |
from soc.views.models import group |
50 |
from soc.views.models import program as program_view |
|
51 |
||
52 |
import soc.models.organization |
|
53 |
import soc.logic.models.organization |
|
54 |
||
55 |
class View(group.View): |
|
56 |
"""View methods for the Organization model. |
|
57 |
""" |
|
58 |
||
59 |
def __init__(self, params=None): |
|
60 |
"""Defines the fields and methods required for the base View class |
|
61 |
to provide the user with list, public, create, edit and delete views. |
|
62 |
||
63 |
Params: |
|
64 |
original_params: a dict with params for this View |
|
65 |
""" |
|
66 |
||
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
67 |
rights = access.Checker(params) |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
68 |
rights['any_access'] = ['allow'] |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
69 |
rights['show'] = ['allow'] |
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
70 |
rights['create'] = ['checkIsDeveloper'] |
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
71 |
rights['edit'] = [('checkHasActiveRoleForKeyFieldsAsScope', |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
72 |
org_admin_logic.logic,), |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
73 |
('checkGroupIsActiveForLinkId', org_logic.logic)] |
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
74 |
rights['delete'] = ['checkIsDeveloper'] |
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
75 |
rights['home'] = ['allow'] |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
76 |
rights['public_list'] = ['allow'] |
1405
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
77 |
rights['apply_mentor'] = ['checkIsUser'] |
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
78 |
rights['list_requests'] = [('checkHasActiveRoleForKeyFieldsAsScope', |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
79 |
org_admin_logic.logic)] |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
80 |
rights['list_roles'] = [('checkHasActiveRoleForKeyFieldsAsScope', |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
81 |
org_admin_logic.logic)] |
1266
e8feadcbc47f
Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1264
diff
changeset
|
82 |
rights['applicant'] = [('checkIsApplicationAccepted', |
e8feadcbc47f
Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1264
diff
changeset
|
83 |
org_app_logic.logic)] |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
84 |
rights['list_proposals'] = [('checkHasAny', [ |
1605
df05cd289b2f
Fixed two bugs introduced in r2160.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1600
diff
changeset
|
85 |
[('checkHasActiveRoleForKeyFieldsAsScope', [org_admin_logic.logic]), |
df05cd289b2f
Fixed two bugs introduced in r2160.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1600
diff
changeset
|
86 |
('checkHasActiveRoleForKeyFieldsAsScope', [mentor_logic.logic])] |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
87 |
])] |
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
88 |
|
682 | 89 |
new_params = {} |
90 |
new_params['logic'] = soc.logic.models.organization.logic |
|
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
91 |
new_params['rights'] = rights |
682 | 92 |
|
93 |
new_params['scope_view'] = program_view |
|
94 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
|
95 |
||
96 |
new_params['name'] = "Organization" |
|
97 |
new_params['url_name'] = "org" |
|
1303
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1284
diff
changeset
|
98 |
new_params['document_prefix'] = "org" |
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
99 |
new_params['sidebar_grouping'] = 'Organizations' |
682 | 100 |
|
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
101 |
new_params['public_template'] = 'soc/organization/public.html' |
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
102 |
new_params['list_row'] = 'soc/organization/list/row.html' |
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
103 |
new_params['list_heading'] = 'soc/organization/list/heading.html' |
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
104 |
|
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
105 |
new_params['application_logic'] = org_app_logic |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
106 |
new_params['group_applicant_url'] = True |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
107 |
new_params['sans_link_id_public_list'] = True |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
108 |
|
1760
393891d794e2
Hide 'slots' and add 'slots_desired'
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1702
diff
changeset
|
109 |
new_params['extra_dynaexclude'] = ['slots'] |
393891d794e2
Hide 'slots' and add 'slots_desired'
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1702
diff
changeset
|
110 |
|
1405
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
111 |
patterns = [] |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
112 |
|
1702 | 113 |
patterns += [ |
114 |
(r'^%(url_name)s/(?P<access_type>apply_mentor)/%(scope)s$', |
|
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
115 |
'soc.views.models.%(module_name)s.apply_mentor', |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
116 |
"List of all %(name_plural)s you can apply to"), |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
117 |
(r'^%(url_name)s/(?P<access_type>list_proposals)/%(key_fields)s$', |
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
118 |
'soc.views.models.%(module_name)s.list_proposals', |
1702 | 119 |
"List of all Student Proposals for this %(name)s"), |
120 |
] |
|
1405
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
121 |
|
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
122 |
new_params['extra_django_patterns'] = patterns |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
123 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1406
diff
changeset
|
124 |
new_params['create_extra_dynaproperties'] = { |
682 | 125 |
'scope_path': forms.CharField(widget=forms.HiddenInput, |
126 |
required=True), |
|
1683
866667e9343d
Make org description use TinyMCE
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1676
diff
changeset
|
127 |
'description': forms.fields.CharField( |
866667e9343d
Make org description use TinyMCE
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1676
diff
changeset
|
128 |
widget=helper.widgets.FullTinyMCE( |
866667e9343d
Make org description use TinyMCE
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1676
diff
changeset
|
129 |
attrs={'rows': 25, 'cols': 100})), |
1567
b5589e656ed1
Member template in organization is now called Contributor Template.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1526
diff
changeset
|
130 |
'contrib_template': forms.fields.CharField( |
b5589e656ed1
Member template in organization is now called Contributor Template.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1526
diff
changeset
|
131 |
widget=helper.widgets.FullTinyMCE( |
b5589e656ed1
Member template in organization is now called Contributor Template.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1526
diff
changeset
|
132 |
attrs={'rows': 25, 'cols': 100})), |
1683
866667e9343d
Make org description use TinyMCE
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1676
diff
changeset
|
133 |
'clean_description': cleaning.clean_html_content('description'), |
866667e9343d
Make org description use TinyMCE
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1676
diff
changeset
|
134 |
'clean_contrib_template': cleaning.clean_html_content('contrib_template'), |
1391
09a95e57caa7
Added a missing cleaner to org idea list
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1344
diff
changeset
|
135 |
'clean_ideas': cleaning.clean_url('ideas'), |
1221
0130e63704ac
Remove extra whitespaces in soc.views.models.organization module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1205
diff
changeset
|
136 |
'clean': cleaning.validate_new_group('link_id', 'scope_path', |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
137 |
soc.logic.models.organization, org_app_logic) |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
138 |
} |
1205
2e88261aba72
Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1154
diff
changeset
|
139 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1406
diff
changeset
|
140 |
new_params['edit_extra_dynaproperties'] = { |
1700
599a5ff8f422
Clean document references
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1685
diff
changeset
|
141 |
'clean': cleaning.clean_refs(new_params, ['home_link_id']) |
599a5ff8f422
Clean document references
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1685
diff
changeset
|
142 |
} |
682 | 143 |
|
144 |
params = dicts.merge(params, new_params) |
|
145 |
||
146 |
super(View, self).__init__(params=params) |
|
147 |
||
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
148 |
# create and store the special form for applicants |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
149 |
updated_fields = { |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
150 |
'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
151 |
required=False), |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
152 |
'clean_link_id': cleaning.clean_link_id('link_id') |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
153 |
} |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
154 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
155 |
applicant_create_form = dynaform.extendDynaForm( |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
156 |
dynaform = self._params['create_form'], |
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1406
diff
changeset
|
157 |
dynaproperties = updated_fields) |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
158 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
159 |
params['applicant_create_form'] = applicant_create_form |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
160 |
|
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
161 |
@decorators.merge_params |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
162 |
@decorators.check_access |
1405
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
163 |
def applyMentor(self, request, access_type, |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
164 |
page_name=None, params=None, **kwargs): |
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
165 |
"""Shows a list of all organizations and you can choose one to |
1405
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
166 |
apply to become a mentor. |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
167 |
|
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
168 |
Args: |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
169 |
request: the standard Django HTTP request object |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
170 |
access_type : the name of the access type which should be checked |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
171 |
page_name: the page name displayed in templates as page and header title |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
172 |
params: a dict with params for this View |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
173 |
kwargs: the Key Fields for the specified entity |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
174 |
""" |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
175 |
|
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
176 |
list_params = params.copy() |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
177 |
list_params['list_action'] = (redirects.getRequestRedirectForRole, 'mentor') |
1641
c2201decd4b4
Some style fixes, removal of unused imports and add ugettext where it was missing in soc.views.models.organization module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1605
diff
changeset
|
178 |
list_params['list_description'] = ugettext('Choose an Organization which ' |
1405
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
179 |
'you want to become a Mentor for.') |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
180 |
|
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
181 |
filter = {'scope_path': kwargs['scope_path'], |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
182 |
'status' : 'active'} |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
183 |
|
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
184 |
return self.list(request, access_type, |
1405
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
185 |
page_name, params=list_params, filter=filter) |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
186 |
|
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
187 |
@decorators.merge_params |
43b482f48b12
Added apply as a mentor view which lists all orgs for a given program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1391
diff
changeset
|
188 |
@decorators.check_access |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
189 |
def listProposals(self, request, access_type, |
1491
acf7e32de8ca
Style fixes in student_proposal and organization view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1490
diff
changeset
|
190 |
page_name=None, params=None, **kwargs): |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
191 |
"""Lists all proposals for the organization given in kwargs. |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
192 |
|
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
193 |
For params see base.View.public(). |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
194 |
""" |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
195 |
|
1685
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
196 |
from soc.logic.models.ranker_root import logic as ranker_root_logic |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
197 |
from soc.models import student_proposal |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
198 |
from soc.views.models import student_proposal as student_proposal_view |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
199 |
|
1668
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
200 |
try: |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
201 |
org_entity = self._logic.getFromKeyFieldsOr404(kwargs) |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
202 |
except out_of_band.Error, error: |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
203 |
return helper.responses.errorResponse( |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
204 |
error, request, template=params['error_public']) |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
205 |
|
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
206 |
list_params = student_proposal_view.view.getParams().copy() |
1668
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
207 |
|
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
208 |
ranked_params = list_params.copy()# ranked proposals |
1685
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
209 |
ranked_params['list_row'] = ('soc/%(module_name)s/list/' |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
210 |
'detailed_row.html' % list_params) |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
211 |
ranked_params['list_heading'] = ('soc/%(module_name)s/list/' |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
212 |
'detailed_heading.html' % list_params) |
1668
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
213 |
ranked_params['list_description'] = 'List of %s send to %s ' % ( |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
214 |
ranked_params['name_plural'], org_entity.name) |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
215 |
ranked_params['list_action'] = (redirects.getReviewRedirect, ranked_params) |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
216 |
|
1676
a3c33bef2ea8
Organization Proposals list now correctly sorts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1668
diff
changeset
|
217 |
# TODO(ljvderijk) once sorting with IN operator is fixed, |
a3c33bef2ea8
Organization Proposals list now correctly sorts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1668
diff
changeset
|
218 |
# make this list show more |
a3c33bef2ea8
Organization Proposals list now correctly sorts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1668
diff
changeset
|
219 |
filter = {'org': org_entity, |
a3c33bef2ea8
Organization Proposals list now correctly sorts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1668
diff
changeset
|
220 |
'status': 'pending'} |
1668
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
221 |
|
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
222 |
# order by descending score |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
223 |
order = ['-score'] |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
224 |
|
1668
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
225 |
prop_list = lists.getListContent( |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
226 |
request, ranked_params, filter, order=order, idx=0) |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
227 |
|
1685
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
228 |
proposals = prop_list['data'] |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
229 |
|
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
230 |
# get a list of scores |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
231 |
scores = [[proposal.score] for proposal in proposals] |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
232 |
|
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
233 |
# retrieve the ranker |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
234 |
fields = {'link_id': student_proposal.DEF_RANKER_NAME, |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
235 |
'scope': org_entity} |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
236 |
|
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
237 |
ranker_root = ranker_root_logic.getForFields(fields, unique=True) |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
238 |
ranker = ranker_root_logic.getRootFromEntity(ranker_root) |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
239 |
|
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
240 |
# retrieve the ranks for these scores |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
241 |
ranks = [rank+1 for rank in ranker.FindRanks(scores)] |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
242 |
|
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
243 |
# link the proposals to the rank |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
244 |
ranking = dict([i for i in itertools.izip(proposals, ranks)]) |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
245 |
|
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
246 |
# update the prop_list with the ranking information |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
247 |
prop_list['info'] = ((lambda item, cache: {'rank': cache[item]}), ranking) |
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
248 |
|
1668
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
249 |
new_params = list_params.copy() # new proposals |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
250 |
new_params['list_description'] = 'List of new %s send to %s ' %( |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
251 |
new_params['name_plural'], org_entity.name) |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
252 |
new_params['list_action'] = (redirects.getReviewRedirect, new_params) |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
253 |
|
1685
4b48cd4e4aa9
Added a rank column to the proposals list.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1683
diff
changeset
|
254 |
filter = {'org': org_entity, |
1766
75531b82a4e2
Add indention in soc.views.models.organization module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1760
diff
changeset
|
255 |
'status': 'new'} |
1668
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
256 |
|
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
257 |
new_list = lists.getListContent( |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
258 |
request, new_params, filter, idx=1) |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
259 |
|
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
260 |
# fill contents with all the needed lists |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
261 |
contents = [prop_list, new_list] |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
262 |
|
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
263 |
# call the _list method from base to display the list |
e3780ee24322
The organization proposal list has been significantly changed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1641
diff
changeset
|
264 |
return self._list(request, list_params, contents, page_name) |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
265 |
|
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
266 |
@decorators.merge_params |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
267 |
@decorators.check_access |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
268 |
def listPublic(self, request, access_type, page_name=None, |
1491
acf7e32de8ca
Style fixes in student_proposal and organization view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1490
diff
changeset
|
269 |
params=None, filter=None, **kwargs): |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
270 |
"""See base.View.list. |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
271 |
""" |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
272 |
|
1600
0aa3de1b2acc
Fix access bug due to forgotten normalization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1599
diff
changeset
|
273 |
account = accounts.getCurrentAccount() |
1596
834ead6528a8
Fixed a missing .logic in organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1584
diff
changeset
|
274 |
user = user_logic.logic.getForAccount(account) if account else None |
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
275 |
|
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
276 |
try: |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
277 |
rights = self._params['rights'] |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
278 |
rights.setCurrentUser(account, user) |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
279 |
rights.checkIsHost() |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
280 |
is_host = True |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
281 |
except out_of_band.Error: |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
282 |
is_host = False |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
283 |
|
1605
df05cd289b2f
Fixed two bugs introduced in r2160.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1600
diff
changeset
|
284 |
new_params = {} |
df05cd289b2f
Fixed two bugs introduced in r2160.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1600
diff
changeset
|
285 |
|
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1491
diff
changeset
|
286 |
if is_host: |
1344
d94410538f8e
Redirect to the admin view in listPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
287 |
new_params['list_action'] = (redirects.getAdminRedirect, params) |
d94410538f8e
Redirect to the admin view in listPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
288 |
else: |
d94410538f8e
Redirect to the admin view in listPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
289 |
new_params['list_action'] = (redirects.getPublicRedirect, params) |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
290 |
# safe to merge them the wrong way around because of @merge_params |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
291 |
params = dicts.merge(new_params, params) |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
292 |
|
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
293 |
new_filter = {} |
1406
60b68fc36df2
List public view for organizations should be program limited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1405
diff
changeset
|
294 |
|
60b68fc36df2
List public view for organizations should be program limited.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1405
diff
changeset
|
295 |
new_filter['scope_path'] = kwargs['scope_path'] |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
296 |
new_filter['status'] = 'active' |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
297 |
filter = dicts.merge(filter, new_filter) |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
298 |
|
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
299 |
content = lists.getListContent(request, params, filter) |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
300 |
contents = [content] |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
301 |
|
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1317
diff
changeset
|
302 |
return self._list(request, params, contents, page_name) |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1126
diff
changeset
|
303 |
|
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
304 |
def _getExtraMenuItems(self, role_description, params=None): |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
305 |
"""Used to create the specific Organization menu entries. |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
306 |
|
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
307 |
For args see group.View._getExtraMenuItems(). |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
308 |
""" |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
309 |
submenus = [] |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
310 |
|
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
311 |
group_entity = role_description['group'] |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
312 |
roles = role_description['roles'] |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
313 |
|
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
314 |
if roles.get('org_admin') or roles.get('mentor'): |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
315 |
# add a link to view all the student proposals |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
316 |
submenu = (redirects.getListProposalsRedirect(group_entity, params), |
1490
cb7a272bfd04
Textual changes in organization and program view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1489
diff
changeset
|
317 |
"View all Student Proposals", 'any_access') |
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
318 |
submenus.append(submenu) |
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
319 |
|
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
320 |
|
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
321 |
if roles.get('org_admin'): |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
322 |
# add a link to the management page |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
323 |
submenu = (redirects.getListRolesRedirect(group_entity, params), |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
324 |
"Manage Admins and Mentors", 'any_access') |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
325 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
326 |
|
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
327 |
# add a link to invite an org admin |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
328 |
submenu = (redirects.getInviteRedirectForRole(group_entity, 'org_admin'), |
1463
d25793debbfb
Remove superfluous 'Org' in links
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1436
diff
changeset
|
329 |
"Invite an Admin", 'any_access') |
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
330 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
331 |
|
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
332 |
# add a link to invite a member |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
333 |
submenu = (redirects.getInviteRedirectForRole(group_entity, 'mentor'), |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
334 |
"Invite a Mentor", 'any_access') |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
335 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
336 |
|
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
337 |
# add a link to the request page |
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
338 |
submenu = (redirects.getListRequestsRedirect(group_entity, params), |
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
339 |
"List Requests and Invites", 'any_access') |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
340 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
341 |
|
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
342 |
# add a link to the edit page |
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
343 |
submenu = (redirects.getEditRedirect(group_entity, params), |
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
344 |
"Edit Organization Profile", 'any_access') |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
345 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
346 |
|
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
347 |
if roles.get('org_admin') or roles.get('mentor'): |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
348 |
submenu = (redirects.getCreateDocumentRedirect(group_entity, 'org'), |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
349 |
"Create a New Document", 'any_access') |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
350 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
351 |
|
1317
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
352 |
submenu = (redirects.getListDocumentsRedirect(group_entity, 'org'), |
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
353 |
"List Documents", 'any_access') |
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
354 |
submenus.append(submenu) |
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
355 |
|
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
356 |
|
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
357 |
if roles.get('org_admin'): |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1266
diff
changeset
|
358 |
# add a link to the resign page |
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
359 |
submenu = (redirects.getManageRedirect(roles['org_admin'], |
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
360 |
{'url_name': 'org_admin'}), |
1463
d25793debbfb
Remove superfluous 'Org' in links
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1436
diff
changeset
|
361 |
"Resign as Admin", 'any_access') |
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
362 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
363 |
|
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1266
diff
changeset
|
364 |
# add a link to the edit page |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1266
diff
changeset
|
365 |
submenu = (redirects.getEditRedirect(roles['org_admin'], |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1266
diff
changeset
|
366 |
{'url_name': 'org_admin'}), |
1463
d25793debbfb
Remove superfluous 'Org' in links
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1436
diff
changeset
|
367 |
"Edit My Admin Profile", 'any_access') |
1283
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1266
diff
changeset
|
368 |
submenus.append(submenu) |
438dceed3132
Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1266
diff
changeset
|
369 |
|
1489
e12e08c8b258
Added view for organizations to list all proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1463
diff
changeset
|
370 |
|
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
371 |
if roles.get('mentor'): |
1284
92f7a24d8f42
Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1283
diff
changeset
|
372 |
# add a link to the resign page |
1599
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
373 |
submenu = (redirects.getManageRedirect(roles['mentor'], |
b56976cac36b
Add myself to authors on this file, and allow my whitespace cleanup hook to cleanup whitespace.
Augie Fackler <durin42@gmail.com>
parents:
1598
diff
changeset
|
374 |
{'url_name' : 'mentor'}), |
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
375 |
"Resign as Mentor", 'any_access') |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
376 |
submenus.append(submenu) |
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
377 |
|
1284
92f7a24d8f42
Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1283
diff
changeset
|
378 |
# add a link to the edit page |
92f7a24d8f42
Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1283
diff
changeset
|
379 |
submenu = (redirects.getEditRedirect(roles['mentor'], |
92f7a24d8f42
Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1283
diff
changeset
|
380 |
{'url_name': 'mentor'}), |
1463
d25793debbfb
Remove superfluous 'Org' in links
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1436
diff
changeset
|
381 |
"Edit My Mentor Profile", 'any_access') |
1284
92f7a24d8f42
Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1283
diff
changeset
|
382 |
submenus.append(submenu) |
92f7a24d8f42
Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1283
diff
changeset
|
383 |
|
1264
4d46b09f3751
Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1221
diff
changeset
|
384 |
return submenus |
1126
4fc86db70a76
Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
385 |
|
682 | 386 |
|
387 |
view = View() |
|
388 |
||
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
389 |
admin = decorators.view(view.admin) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
390 |
applicant = decorators.view(view.applicant) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
391 |
apply_mentor = decorators.view(view.applyMentor) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
392 |
create = decorators.view(view.create) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
393 |
delete = decorators.view(view.delete) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
394 |
edit = decorators.view(view.edit) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
395 |
home = decorators.view(view.home) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
396 |
list = decorators.view(view.list) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
397 |
list_proposals = decorators.view(view.listProposals) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
398 |
list_public = decorators.view(view.listPublic) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
399 |
list_requests = decorators.view(view.listRequests) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
400 |
list_roles = decorators.view(view.listRoles) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
401 |
public = decorators.view(view.public) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
402 |
export = decorators.view(view.export) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1567
diff
changeset
|
403 |
pick = decorators.view(view.pick) |