author | Sverre Rabbelier <srabbelier@gmail.com> |
Thu, 26 Feb 2009 16:49:45 +0000 | |
changeset 1513 | 13efb916a73c |
parent 1512 | 97c4a718d6f4 |
child 1564 | 49a9858c8803 |
permissions | -rw-r--r-- |
643 | 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. |
643 | 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 Programs. |
|
18 |
""" |
|
19 |
||
20 |
__authors__ = [ |
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
769
a0ee643fe832
Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
755
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
643 | 23 |
] |
24 |
||
25 |
||
26 |
from django import forms |
|
1260
594c6b500378
Added Agreement properties to Program Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1257
diff
changeset
|
27 |
from django.utils.translation import ugettext |
643 | 28 |
|
29 |
from soc.logic import dicts |
|
1209
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
30 |
from soc.logic.helper import timeline as timeline_helper |
1273
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
31 |
from soc.logic.models import host as host_logic |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
32 |
from soc.logic.models import mentor as mentor_logic |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
33 |
from soc.logic.models import org_admin as org_admin_logic |
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
777
diff
changeset
|
34 |
from soc.logic.models import program as program_logic |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
35 |
from soc.logic.models import student as student_logic |
1352
4f118840617f
Fix import sorting in soc.views.models.program module and rename any "Org" in link names to "Organization".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
36 |
from soc.logic.models.document import logic as document_logic |
666
b9b0506efe8d
Fix import sorting and docstring typos in soc.views.models.program module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
663
diff
changeset
|
37 |
from soc.views import helper |
1038
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
38 |
from soc.views import out_of_band |
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
39 |
from soc.views.helper import access |
1038
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
40 |
from soc.views.helper import decorators |
643 | 41 |
from soc.views.helper import redirects |
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
777
diff
changeset
|
42 |
from soc.views.helper import widgets |
1053
3b9552cf748a
Rename the confusing Tossed Model class to PresenceWithToS.
Todd Larsen <tlarsen@google.com>
parents:
1051
diff
changeset
|
43 |
from soc.views.models import presence_with_tos |
714
3e2ce3d8057a
Add missing dots in docstrings, proper sorting of imports and small docstring typo fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
712
diff
changeset
|
44 |
from soc.views.models import document as document_view |
643 | 45 |
from soc.views.models import sponsor as sponsor_view |
705
0ab17e14df95
Move document sidebar entries extraction to document.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
700
diff
changeset
|
46 |
from soc.views.sitemap import sidebar |
643 | 47 |
|
48 |
import soc.logic.models.program |
|
1260
594c6b500378
Added Agreement properties to Program Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1257
diff
changeset
|
49 |
import soc.models.work |
643 | 50 |
|
51 |
||
1053
3b9552cf748a
Rename the confusing Tossed Model class to PresenceWithToS.
Todd Larsen <tlarsen@google.com>
parents:
1051
diff
changeset
|
52 |
class View(presence_with_tos.View): |
666
b9b0506efe8d
Fix import sorting and docstring typos in soc.views.models.program module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
663
diff
changeset
|
53 |
"""View methods for the Program model. |
643 | 54 |
""" |
55 |
||
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
56 |
def __init__(self, params=None): |
643 | 57 |
"""Defines the fields and methods required for the base View class |
58 |
to provide the user with list, public, create, edit and delete views. |
|
59 |
||
60 |
Params: |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
61 |
params: a dict with params for this View |
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
62 |
""" |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
63 |
|
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
64 |
rights = access.Checker(params) |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
65 |
rights['any_access'] = ['allow'] |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
66 |
rights['show'] = ['allow'] |
1248
f318538394d9
Rename checkHasActiveRole to checkHasActiveRoleForScope
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1238
diff
changeset
|
67 |
rights['create'] = [('checkSeeded', ['checkHasActiveRoleForScope', host_logic.logic])] |
1074
94bc2a9ae103
Properly check if a program is active
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1053
diff
changeset
|
68 |
rights['edit'] = ['checkIsHostForProgram'] |
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
69 |
rights['delete'] = ['checkIsDeveloper'] |
643 | 70 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
71 |
new_params = {} |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
72 |
new_params['logic'] = soc.logic.models.program.logic |
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
73 |
new_params['rights'] = rights |
643 | 74 |
|
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
75 |
new_params['scope_view'] = sponsor_view |
681
48983ecf4665
Cleanups in group and program
Sverre Rabbelier <srabbelier@gmail.com>
parents:
680
diff
changeset
|
76 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
77 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
78 |
new_params['name'] = "Program" |
1025
1f83f05f522b
Add grouping to the existing views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1024
diff
changeset
|
79 |
new_params['sidebar_grouping'] = 'Programs' |
1303
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
80 |
new_params['document_prefix'] = "program" |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
81 |
|
1511
3342ce7a495c
Fix some whitespace damadge and a style fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1492
diff
changeset
|
82 |
new_params['extra_dynaexclude'] = ['timeline', 'org_admin_agreement', |
1260
594c6b500378
Added Agreement properties to Program Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1257
diff
changeset
|
83 |
'mentor_agreement', 'student_agreement'] |
810
208659644a7f
Hide 'tos' pull-down selector from Program profile forms.
Todd Larsen <tlarsen@google.com>
parents:
799
diff
changeset
|
84 |
|
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
85 |
# TODO add clean field to check for uniqueness in link_id and scope_path |
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1352
diff
changeset
|
86 |
new_params['create_extra_dynaproperties'] = { |
649 | 87 |
'description': forms.fields.CharField(widget=helper.widgets.TinyMCE( |
668
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
666
diff
changeset
|
88 |
attrs={'rows':10, 'cols':40})), |
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
666
diff
changeset
|
89 |
'scope_path': forms.CharField(widget=forms.HiddenInput, required=True), |
1144
f89bbc9b20a6
Rename 'Create a new document' links to 'Create a New Document', also rename 'Create a new Program' to 'Create a New Program' in soc.views.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1115
diff
changeset
|
90 |
'workflow': forms.ChoiceField(choices=[('gsoc','Project-based'), |
769
a0ee643fe832
Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
755
diff
changeset
|
91 |
('ghop','Task-based')], required=True), |
643 | 92 |
} |
93 |
||
1303
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
94 |
reference_fields = [ |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
95 |
('org_admin_agreement_link_id', soc.models.work.Work.link_id.help_text, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
96 |
ugettext('Organization Admin Agreement Document link ID')), |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
97 |
('mentor_agreement_link_id', soc.models.work.Work.link_id.help_text, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
98 |
ugettext('Mentor Agreement Document link ID')), |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
99 |
('student_agreement_link_id', soc.models.work.Work.link_id.help_text, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
100 |
ugettext('Student Agreement Document link ID')), |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
101 |
('home_link_id', soc.models.work.Work.link_id.help_text, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
102 |
ugettext('Home page Document link ID')), |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
103 |
('tos_link_id', soc.models.work.Work.link_id.help_text, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
104 |
ugettext('Terms of Service Document link ID')) |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
105 |
] |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
106 |
|
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
107 |
result = {} |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
108 |
|
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
109 |
for key, help_text, label in reference_fields: |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
110 |
result[key] = widgets.ReferenceField( |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
111 |
reference_url='document', filter=['__scoped__'], |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
112 |
filter_fields={'prefix': new_params['document_prefix']}, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
113 |
required=False, label=label, help_text=help_text) |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
114 |
|
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
115 |
result['workflow'] = forms.CharField(widget=widgets.ReadOnlyInput(), |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
116 |
required=True) |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
117 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1352
diff
changeset
|
118 |
new_params['edit_extra_dynaproperties'] = result |
1303
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1281
diff
changeset
|
119 |
|
1273
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
120 |
references = [ |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
121 |
('org_admin_agreement_link_id', 'org_admin_agreement', document_logic, |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
122 |
lambda x: x.org_admin_agreement), |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
123 |
('mentor_agreement_link_id', 'mentor_agreement', document_logic, |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
124 |
lambda x: x.mentor_agreement), |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
125 |
('student_agreement_link_id', 'student_agreement', document_logic, |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
126 |
lambda x: x.student_agreement), |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
127 |
] |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
128 |
|
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
129 |
new_params['references'] = references |
324a1ecc4e88
Use the newly added __scoped__ and references for program's ToSes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1260
diff
changeset
|
130 |
|
1260
594c6b500378
Added Agreement properties to Program Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1257
diff
changeset
|
131 |
params = dicts.merge(params, new_params, sub_merge=True) |
643 | 132 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
133 |
super(View, self).__init__(params=params) |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
134 |
|
769
a0ee643fe832
Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
755
diff
changeset
|
135 |
def _editPost(self, request, entity, fields): |
a0ee643fe832
Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
755
diff
changeset
|
136 |
"""See base._editPost(). |
a0ee643fe832
Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
755
diff
changeset
|
137 |
""" |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
138 |
|
1475
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1470
diff
changeset
|
139 |
super(View, self)._editPost(request, entity, fields) |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1470
diff
changeset
|
140 |
|
770
eb2e69312953
Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
769
diff
changeset
|
141 |
if not entity: |
eb2e69312953
Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
769
diff
changeset
|
142 |
# there is no existing entity so create a new timeline |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
143 |
fields['timeline'] = self._createTimelineForType(fields) |
770
eb2e69312953
Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
769
diff
changeset
|
144 |
else: |
eb2e69312953
Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
769
diff
changeset
|
145 |
# use the timeline from the entity |
eb2e69312953
Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
769
diff
changeset
|
146 |
fields['timeline'] = entity.timeline |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
147 |
|
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
148 |
def _createTimelineForType(self, fields): |
771
0b1beae179f5
Typo and style fixes.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
770
diff
changeset
|
149 |
"""Creates and stores a timeline model for the given type of program. |
769
a0ee643fe832
Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
755
diff
changeset
|
150 |
""" |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
151 |
|
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
152 |
workflow = fields['workflow'] |
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
153 |
|
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
777
diff
changeset
|
154 |
timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow] |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
155 |
|
1512
97c4a718d6f4
Remove updateOrCreateFromFields and it's uses
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1511
diff
changeset
|
156 |
properties = timeline_logic.getKeyFieldsFromFields(fields) |
97c4a718d6f4
Remove updateOrCreateFromFields and it's uses
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1511
diff
changeset
|
157 |
key_name = timeline_logic.getKeyNameFromFields(properties) |
97c4a718d6f4
Remove updateOrCreateFromFields and it's uses
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1511
diff
changeset
|
158 |
|
1475
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1470
diff
changeset
|
159 |
properties['scope'] = fields['scope'] |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
160 |
|
1512
97c4a718d6f4
Remove updateOrCreateFromFields and it's uses
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1511
diff
changeset
|
161 |
timeline = timeline_logic.updateOrCreateFromKeyName(properties, key_name) |
777
16dcdb8f3357
Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
771
diff
changeset
|
162 |
return timeline |
643 | 163 |
|
1038
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
164 |
@decorators.merge_params |
1017
6ad4fdb48840
Cache access checks and disable sidebar caching
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
165 |
def getExtraMenus(self, id, user, params=None): |
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
166 |
"""Returns the extra menu's for this view. |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
167 |
|
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
168 |
A menu item is generated for each program that is currently |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
169 |
running. The public page for each program is added as menu item, |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
170 |
as well as all public documents for that program. |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
171 |
|
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
172 |
Args: |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
173 |
params: a dict with params for this View. |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
174 |
""" |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
175 |
|
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
176 |
logic = params['logic'] |
1038
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
177 |
rights = params['rights'] |
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
178 |
|
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
179 |
# only get all invisible and visible programs |
1511
3342ce7a495c
Fix some whitespace damadge and a style fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1492
diff
changeset
|
180 |
fields = {'status': ['invisible', 'visible']} |
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
181 |
entities = logic.getForFields(fields) |
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
182 |
|
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
183 |
menus = [] |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
184 |
|
1038
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
185 |
rights.setCurrentUser(id, user) |
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
186 |
filter_args = {} |
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
187 |
|
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
188 |
for entity in entities: |
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
189 |
items = [] |
1038
0a0bc446f869
Allow for a program on/off switch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1036
diff
changeset
|
190 |
|
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
191 |
if entity.status == 'visible': |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
192 |
# show the documents for this program, even for not logged in users |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
193 |
items += document_view.view.getMenusForScope(entity, params) |
1317
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
194 |
items += self._getTimeDependentEntries(entity, params, id, user) |
1097
1f7015b33a0c
Add a 'Create new document' link for clubs, sponsors and programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1074
diff
changeset
|
195 |
|
1f7015b33a0c
Add a 'Create new document' link for clubs, sponsors and programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1074
diff
changeset
|
196 |
try: |
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
197 |
# check if the current user is a host for this program |
1511
3342ce7a495c
Fix some whitespace damadge and a style fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1492
diff
changeset
|
198 |
rights.doCachedCheck('checkIsHostForProgram', |
1325
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1321
diff
changeset
|
199 |
{'scope_path': entity.scope_path, |
8368086dd3a7
Add a list_public view to organization
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1321
diff
changeset
|
200 |
'link_id': entity.link_id}, []) |
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
201 |
|
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
202 |
if entity.status == 'invisible': |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
203 |
# still add the document links so hosts can see how it looks like |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
204 |
items += document_view.view.getMenusForScope(entity, params) |
1321
0e587b1d0c1d
Fixed missing parameters in program view due to change in _getTimeDependentEntries in r1943.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1317
diff
changeset
|
205 |
items += self._getTimeDependentEntries(entity, params, id, user) |
1257
12d2bf06698f
Added a button to list all your org applications to a speficic program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1248
diff
changeset
|
206 |
|
1238
af56ae7397ab
Added scoped group_app listing.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1225
diff
changeset
|
207 |
items += [(redirects.getReviewOverviewRedirect( |
af56ae7397ab
Added scoped group_app listing.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1225
diff
changeset
|
208 |
entity, {'url_name': 'org_app'}), |
1352
4f118840617f
Fix import sorting in soc.views.models.program module and rename any "Org" in link names to "Organization".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
209 |
"Review Organization Applications", 'any_access')] |
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
210 |
# add link to edit Program Profile |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
211 |
items += [(redirects.getEditRedirect(entity, params), |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
212 |
'Edit Program Profile','any_access')] |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
213 |
# add link to edit Program Timeline |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
214 |
items += [(redirects.getEditRedirect(entity, {'url_name': 'timeline'}), |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
215 |
"Edit Program Timeline", 'any_access')] |
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
216 |
# add link to create a new Program Document |
1097
1f7015b33a0c
Add a 'Create new document' link for clubs, sponsors and programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1074
diff
changeset
|
217 |
items += [(redirects.getCreateDocumentRedirect(entity, 'program'), |
1144
f89bbc9b20a6
Rename 'Create a new document' links to 'Create a New Document', also rename 'Create a new Program' to 'Create a New Program' in soc.views.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1115
diff
changeset
|
218 |
"Create a New Document", 'any_access')] |
1317
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
219 |
# add link to list all Program Document |
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
220 |
items += [(redirects.getListDocumentsRedirect(entity, 'program'), |
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
221 |
"List Documents", 'any_access')] |
1107
a878188e225c
Added status to program.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1097
diff
changeset
|
222 |
|
1097
1f7015b33a0c
Add a 'Create new document' link for clubs, sponsors and programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1074
diff
changeset
|
223 |
except out_of_band.Error: |
1f7015b33a0c
Add a 'Create new document' link for clubs, sponsors and programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1074
diff
changeset
|
224 |
pass |
1f7015b33a0c
Add a 'Create new document' link for clubs, sponsors and programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1074
diff
changeset
|
225 |
|
1162
1d9396d75c13
Do not return empty menu's in program.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
226 |
items = sidebar.getSidebarMenu(id, user, items, params=params) |
1d9396d75c13
Do not return empty menu's in program.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
227 |
if not items: |
1d9396d75c13
Do not return empty menu's in program.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
228 |
continue |
1d9396d75c13
Do not return empty menu's in program.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
229 |
|
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
230 |
menu = {} |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
231 |
menu['heading'] = entity.short_name |
1162
1d9396d75c13
Do not return empty menu's in program.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
232 |
menu['items'] = items |
1024
2a0ae6483825
Group dynamically generated menu items
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1023
diff
changeset
|
233 |
menu['group'] = 'Programs' |
700
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
234 |
menus.append(menu) |
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
235 |
|
8baf8367340d
Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
681
diff
changeset
|
236 |
return menus |
647
355ac73823a1
Swap order of merged params to fix sponsor select view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
643
diff
changeset
|
237 |
|
1317
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
238 |
def _getTimeDependentEntries(self, program_entity, params, id, user): |
1209
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
239 |
items = [] |
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
240 |
|
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
241 |
#TODO(ljvderijk) Add more timeline dependent entries |
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
242 |
timeline_entity = program_entity.timeline |
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
243 |
|
1321
0e587b1d0c1d
Fixed missing parameters in program view due to change in _getTimeDependentEntries in r1943.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1317
diff
changeset
|
244 |
if timeline_helper.isActivePeriod(timeline_entity, 'org_signup'): |
1209
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
245 |
# add the organization signup link |
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
246 |
items += [ |
1225
1d5c58e24fd3
Org applications can now only be made by a user when a program allows it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1218
diff
changeset
|
247 |
(redirects.getApplyRedirect(program_entity, {'url_name': 'org_app'}), |
1209
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
248 |
"Apply to become an Organization", 'any_access')] |
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
249 |
|
1321
0e587b1d0c1d
Fixed missing parameters in program view due to change in _getTimeDependentEntries in r1943.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1317
diff
changeset
|
250 |
if user: |
1352
4f118840617f
Fix import sorting in soc.views.models.program module and rename any "Org" in link names to "Organization".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
251 |
# add the 'List my Organization Applications' link |
1321
0e587b1d0c1d
Fixed missing parameters in program view due to change in _getTimeDependentEntries in r1943.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1317
diff
changeset
|
252 |
items += [ |
1511
3342ce7a495c
Fix some whitespace damadge and a style fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1492
diff
changeset
|
253 |
(redirects.getListSelfRedirect(program_entity, |
1321
0e587b1d0c1d
Fixed missing parameters in program view due to change in _getTimeDependentEntries in r1943.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1317
diff
changeset
|
254 |
{'url_name' : 'org_app'}), |
1352
4f118840617f
Fix import sorting in soc.views.models.program module and rename any "Org" in link names to "Organization".
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1343
diff
changeset
|
255 |
"List My Organization Applications", 'any_access')] |
1257
12d2bf06698f
Added a button to list all your org applications to a speficic program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1248
diff
changeset
|
256 |
|
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
257 |
# get the student entity for this user and program |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
258 |
filter = {'user': user, |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
259 |
'scope': program_entity} |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
260 |
student_entity = student_logic.logic.getForFields(filter, unique=True) |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
261 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
262 |
if student_entity: |
1470
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
263 |
items += self._getStudentEntries(program_entity, student_entity, |
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
264 |
params, id, user) |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
265 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
266 |
# get mentor and org_admin entity for this user and program |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
267 |
filter = {'user': user, |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
268 |
'program': program_entity} |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
269 |
mentor_entity = mentor_logic.logic.getForFields(filter, unique=True) |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
270 |
org_admin_entity = org_admin_logic.logic.getForFields(filter, unique=True) |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
271 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
272 |
if mentor_entity or org_admin_entity: |
1470
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
273 |
items += self._getOrganizationEntries(program_entity, org_admin_entity, |
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
274 |
mentor_entity, params, id, user) |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
275 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
276 |
if not (student_entity or mentor_entity or org_admin_entity): |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
277 |
if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
278 |
# this user does not have a role yet for this program |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
279 |
items += [('/student/apply/%s' % (program_entity.key().name()), |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
280 |
"Register as a Student", 'any_access')] |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
281 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
282 |
if timeline_helper.isAfterEvent(timeline_entity, |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
283 |
'accepted_organization_announced_deadline'): |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
284 |
# add a link to list all the organizations |
1511
3342ce7a495c
Fix some whitespace damadge and a style fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1492
diff
changeset
|
285 |
items += [(redirects.getPublicListRedirect(program_entity, {'url_name': 'org'}), |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
286 |
"List participating Organizations", 'any_access')] |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
287 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
288 |
if not student_entity: |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
289 |
# add apply to become a mentor link |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
290 |
items += [('/org/apply_mentor/%s' % (program_entity.key().name()), |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
291 |
"Apply to become a Mentor", 'any_access')] |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
292 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
293 |
return items |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
294 |
|
1470
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
295 |
def _getStudentEntries(self, program_entity, student_entity, params, id, user): |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
296 |
"""Returns a list with menu items for students in a specific program. |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
297 |
""" |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
298 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
299 |
items = [] |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
300 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
301 |
timeline_entity = program_entity.timeline |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
302 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
303 |
if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): |
1483
f5d1229e9360
Added link in program menu to the new list_orgs view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1475
diff
changeset
|
304 |
items += [('/student_proposal/list_orgs/%s' % (student_entity.key().name()), |
1492
deac044c10b6
Textual change in program menu due to comment on r2113.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1490
diff
changeset
|
305 |
"Submit your Student Proposal", 'any_access')] |
1470
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
306 |
items += [(redirects.getListSelfRedirect(student_entity, |
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
307 |
{'url_name':'student_proposal'}), |
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
308 |
"List my Student Proposals", 'any_access')] |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
309 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
310 |
return items |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
311 |
|
1470
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
312 |
def _getOrganizationEntries(self, program_entity, org_admin_entity, |
5e887fb80921
Added list my Student Proposals link to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1437
diff
changeset
|
313 |
mentor_entity, params, id, user): |
1511
3342ce7a495c
Fix some whitespace damadge and a style fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1492
diff
changeset
|
314 |
"""Returns a list with menu items for org admins and mentors in a |
1437
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
315 |
specific program. |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
316 |
""" |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
317 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
318 |
# TODO(ljvderijk) think about adding specific org items like submit review |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
319 |
|
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
320 |
items = [] |
eec60d5bbe95
Added several menu items to the program menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1430
diff
changeset
|
321 |
|
1209
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
322 |
return items |
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
323 |
|
c875b0836f77
Specific program menu's now show a "Apply to become an Organization" entry when the program's timeline states that it's open.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1203
diff
changeset
|
324 |
|
643 | 325 |
view = View() |
326 |
||
1343
4ba39392c854
Hook up the admin view everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1325
diff
changeset
|
327 |
admin = view.admin |
643 | 328 |
create = view.create |
329 |
delete = view.delete |
|
330 |
edit = view.edit |
|
331 |
list = view.list |
|
332 |
public = view.public |
|
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
810
diff
changeset
|
333 |
export = view.export |
923
5a10f6db154b
Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents:
901
diff
changeset
|
334 |
home = view.home |
934
9fcc08971efe
Add a 'pick' view to the appropriate views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
923
diff
changeset
|
335 |
pick = view.pick |