72 " profiles. You can learn more about each organization by" |
73 " profiles. You can learn more about each organization by" |
73 " visiting the links below.") |
74 " visiting the links below.") |
74 |
75 |
75 DEF_SLOTS_ALLOCATION_MSG = ugettext("Use this view to assign slots.") |
76 DEF_SLOTS_ALLOCATION_MSG = ugettext("Use this view to assign slots.") |
76 |
77 |
|
78 DEF_ACCEPTED_PROJECTS_MSG_FMT = ugettext("These projects have been" |
|
79 " accepted into %(name)s. You can learn more about each project" |
|
80 " by visiting the links below.") |
|
81 |
77 def __init__(self, params=None): |
82 def __init__(self, params=None): |
78 """Defines the fields and methods required for the base View class |
83 """Defines the fields and methods required for the base View class |
79 to provide the user with list, public, create, edit and delete views. |
84 to provide the user with list, public, create, edit and delete views. |
80 |
85 |
81 Params: |
86 Params: |
93 rights['slots'] = ['checkIsHostForProgram'] |
98 rights['slots'] = ['checkIsHostForProgram'] |
94 rights['show_duplicates'] = ['checkIsHostForProgram'] |
99 rights['show_duplicates'] = ['checkIsHostForProgram'] |
95 rights['assigned_proposals'] = ['checkIsHostForProgram'] |
100 rights['assigned_proposals'] = ['checkIsHostForProgram'] |
96 rights['accepted_orgs'] = [('checkIsAfterEvent', |
101 rights['accepted_orgs'] = [('checkIsAfterEvent', |
97 ['accepted_organization_announced_deadline', '__all__'])] |
102 ['accepted_organization_announced_deadline', '__all__'])] |
|
103 rights['list_projects'] = [('checkIsAfterEvent', |
|
104 ['accepted_students_announced_deadline', '__all__'])] |
98 |
105 |
99 new_params = {} |
106 new_params = {} |
100 new_params['logic'] = soc.logic.models.program.logic |
107 new_params['logic'] = soc.logic.models.program.logic |
101 new_params['rights'] = rights |
108 new_params['rights'] = rights |
102 |
109 |
125 'soc.views.models.%(module_name)s.assigned_proposals', |
132 'soc.views.models.%(module_name)s.assigned_proposals', |
126 "Assigned proposals for multiple organizations"), |
133 "Assigned proposals for multiple organizations"), |
127 (r'^%(url_name)s/(?P<access_type>accepted_orgs)/%(key_fields)s$', |
134 (r'^%(url_name)s/(?P<access_type>accepted_orgs)/%(key_fields)s$', |
128 'soc.views.models.%(module_name)s.accepted_orgs', |
135 'soc.views.models.%(module_name)s.accepted_orgs', |
129 "List all accepted organizations"), |
136 "List all accepted organizations"), |
|
137 (r'^%(url_name)s/(?P<access_type>list_projects)/%(key_fields)s$', |
|
138 'soc.views.models.%(module_name)s.list_projects', |
|
139 "List all student projects"), |
130 ] |
140 ] |
131 |
141 |
132 new_params['extra_django_patterns'] = patterns |
142 new_params['extra_django_patterns'] = patterns |
133 |
143 |
134 new_params['create_dynafields'] = [ |
144 new_params['create_dynafields'] = [ |
265 |
275 |
266 contents.append(ao_list) |
276 contents.append(ao_list) |
267 |
277 |
268 params = params.copy() |
278 params = params.copy() |
269 params['list_msg'] = program_entity.accepted_orgs_msg |
279 params['list_msg'] = program_entity.accepted_orgs_msg |
|
280 |
|
281 return self._list(request, params, contents, page_name) |
|
282 |
|
283 @decorators.merge_params |
|
284 @decorators.check_access |
|
285 def acceptedProjects(self, request, access_type, |
|
286 page_name=None, params=None, filter=None, **kwargs): |
|
287 """See base.View.list. |
|
288 """ |
|
289 contents = [] |
|
290 logic = params['logic'] |
|
291 |
|
292 program_entity = logic.getFromKeyFieldsOr404(kwargs) |
|
293 |
|
294 filter = { |
|
295 'status': 'accepted', |
|
296 'program': program_entity } |
|
297 |
|
298 fmt = {'name': program_entity.name} |
|
299 description = self.DEF_ACCEPTED_PROJECTS_MSG_FMT % fmt |
|
300 |
|
301 from soc.views.models import student_project as sp_view |
|
302 |
|
303 ap_params = sp_view.view.getParams().copy() # accepted projects |
|
304 |
|
305 fun = soc.cache.logic.cache(self._getData) |
|
306 ap_logic = ap_params['logic'] |
|
307 entities = fun(logic.getModel(), filter, order=None, logic=ap_logic) |
|
308 |
|
309 ap_list = dicts.rename(ap_params, ap_params['list_params']) |
|
310 ap_list['action'] = (redirects.getPublicRedirect, ap_params) |
|
311 ap_list['description'] = description |
|
312 ap_list['pagination'] = 'soc/list/no_pagination.html' |
|
313 ap_list['heading'] = 'soc/student_project/list/heading_all.html' |
|
314 ap_list['row'] = 'soc/student_project/list/row_all.html' |
|
315 ap_list['data'] = entities |
|
316 |
|
317 contents.append(ap_list) |
|
318 |
|
319 params = params.copy() |
270 |
320 |
271 return self._list(request, params, contents, page_name) |
321 return self._list(request, params, contents, page_name) |
272 |
322 |
273 @decorators.merge_params |
323 @decorators.merge_params |
274 @decorators.check_access |
324 @decorators.check_access |
710 if not student_entity: |
760 if not student_entity: |
711 # add apply to become a mentor link |
761 # add apply to become a mentor link |
712 items += [('/org/apply_mentor/%s' % (program_entity.key().id_or_name()), |
762 items += [('/org/apply_mentor/%s' % (program_entity.key().id_or_name()), |
713 "Apply to become a Mentor", 'any_access')] |
763 "Apply to become a Mentor", 'any_access')] |
714 |
764 |
|
765 deadline = 'accepted_students_announced_deadline' |
|
766 |
|
767 if timeline_helper.isAfterEvent(timeline_entity, deadline): |
|
768 items += [(redirects.getListProjectsRedirect(program_entity, |
|
769 {'url_name':'program'}), |
|
770 "List all student projects", 'any_access')] |
|
771 |
715 return items |
772 return items |
716 |
773 |
717 def _getStudentEntries(self, program_entity, student_entity, |
774 def _getStudentEntries(self, program_entity, student_entity, |
718 params, id, user): |
775 params, id, user): |
719 """Returns a list with menu items for students in a specific program. |
776 """Returns a list with menu items for students in a specific program. |
760 |
817 |
761 |
818 |
762 view = View() |
819 view = View() |
763 |
820 |
764 accepted_orgs = decorators.view(view.acceptedOrgs) |
821 accepted_orgs = decorators.view(view.acceptedOrgs) |
|
822 list_projects = decorators.view(view.acceptedProjects) |
765 admin = decorators.view(view.admin) |
823 admin = decorators.view(view.admin) |
766 assign_slots = decorators.view(view.assignSlots) |
824 assign_slots = decorators.view(view.assignSlots) |
767 assigned_proposals = decorators.view(view.assignedProposals) |
825 assigned_proposals = decorators.view(view.assignedProposals) |
768 create = decorators.view(view.create) |
826 create = decorators.view(view.create) |
769 delete = decorators.view(view.delete) |
827 delete = decorators.view(view.delete) |