app/soc/views/models/program.py
changeset 1511 3342ce7a495c
parent 1492 deac044c10b6
child 1512 97c4a718d6f4
equal deleted inserted replaced
1510:bc6dc3bb8d2a 1511:3342ce7a495c
    77 
    77 
    78     new_params['name'] = "Program"
    78     new_params['name'] = "Program"
    79     new_params['sidebar_grouping'] = 'Programs'
    79     new_params['sidebar_grouping'] = 'Programs'
    80     new_params['document_prefix'] = "program"
    80     new_params['document_prefix'] = "program"
    81 
    81 
    82     new_params['extra_dynaexclude'] = ['timeline', 'org_admin_agreement', 
    82     new_params['extra_dynaexclude'] = ['timeline', 'org_admin_agreement',
    83         'mentor_agreement', 'student_agreement']
    83         'mentor_agreement', 'student_agreement']
    84 
    84 
    85     # TODO add clean field to check for uniqueness in link_id and scope_path
    85     # TODO add clean field to check for uniqueness in link_id and scope_path
    86     new_params['create_extra_dynaproperties'] = {
    86     new_params['create_extra_dynaproperties'] = {
    87         'description': forms.fields.CharField(widget=helper.widgets.TinyMCE(
    87         'description': forms.fields.CharField(widget=helper.widgets.TinyMCE(
   174 
   174 
   175     logic = params['logic']
   175     logic = params['logic']
   176     rights = params['rights']
   176     rights = params['rights']
   177 
   177 
   178     # only get all invisible and visible programs
   178     # only get all invisible and visible programs
   179     fields = {'status':['invisible', 'visible']}
   179     fields = {'status': ['invisible', 'visible']}
   180     entities = logic.getForFields(fields)
   180     entities = logic.getForFields(fields)
   181 
   181 
   182     menus = []
   182     menus = []
   183 
   183 
   184     rights.setCurrentUser(id, user)
   184     rights.setCurrentUser(id, user)
   192         items += document_view.view.getMenusForScope(entity, params)
   192         items += document_view.view.getMenusForScope(entity, params)
   193         items += self._getTimeDependentEntries(entity, params, id, user)
   193         items += self._getTimeDependentEntries(entity, params, id, user)
   194 
   194 
   195       try:
   195       try:
   196         # check if the current user is a host for this program
   196         # check if the current user is a host for this program
   197         rights.doCachedCheck('checkIsHostForProgram', 
   197         rights.doCachedCheck('checkIsHostForProgram',
   198                              {'scope_path': entity.scope_path,
   198                              {'scope_path': entity.scope_path,
   199                               'link_id': entity.link_id}, [])
   199                               'link_id': entity.link_id}, [])
   200 
   200 
   201         if entity.status == 'invisible':
   201         if entity.status == 'invisible':
   202           # still add the document links so hosts can see how it looks like
   202           # still add the document links so hosts can see how it looks like
   247           "Apply to become an Organization", 'any_access')]
   247           "Apply to become an Organization", 'any_access')]
   248 
   248 
   249       if user:
   249       if user:
   250         # add the 'List my Organization Applications' link
   250         # add the 'List my Organization Applications' link
   251         items += [
   251         items += [
   252             (redirects.getListSelfRedirect(program_entity, 
   252             (redirects.getListSelfRedirect(program_entity,
   253                                            {'url_name' : 'org_app'}),
   253                                            {'url_name' : 'org_app'}),
   254              "List My Organization Applications", 'any_access')]
   254              "List My Organization Applications", 'any_access')]
   255 
   255 
   256     # get the student entity for this user and program
   256     # get the student entity for this user and program
   257     filter = {'user': user,
   257     filter = {'user': user,
   279             "Register as a Student", 'any_access')]
   279             "Register as a Student", 'any_access')]
   280 
   280 
   281     if timeline_helper.isAfterEvent(timeline_entity,
   281     if timeline_helper.isAfterEvent(timeline_entity,
   282         'accepted_organization_announced_deadline'):
   282         'accepted_organization_announced_deadline'):
   283       # add a link to list all the organizations
   283       # add a link to list all the organizations
   284       items += [(redirects.getPublicListRedirect(program_entity, {'url_name': 'org'}), 
   284       items += [(redirects.getPublicListRedirect(program_entity, {'url_name': 'org'}),
   285           "List participating Organizations", 'any_access')]
   285           "List participating Organizations", 'any_access')]
   286 
   286 
   287       if not student_entity:
   287       if not student_entity:
   288         # add apply to become a mentor link
   288         # add apply to become a mentor link
   289         items += [('/org/apply_mentor/%s' % (program_entity.key().name()),
   289         items += [('/org/apply_mentor/%s' % (program_entity.key().name()),
   308 
   308 
   309     return items
   309     return items
   310 
   310 
   311   def _getOrganizationEntries(self, program_entity, org_admin_entity,
   311   def _getOrganizationEntries(self, program_entity, org_admin_entity,
   312                               mentor_entity, params, id, user):
   312                               mentor_entity, params, id, user):
   313     """Returns a list with menu items for org admins and mentors in a 
   313     """Returns a list with menu items for org admins and mentors in a
   314        specific program.
   314        specific program.
   315     """
   315     """
   316 
   316 
   317     # TODO(ljvderijk) think about adding specific org items like submit review
   317     # TODO(ljvderijk) think about adding specific org items like submit review
   318 
   318