app/soc/views/models/program.py
changeset 1940 609128cc37f7
parent 1930 2222bed78e7f
child 1959 e6644c70e408
equal deleted inserted replaced
1939:a1c53f546603 1940:609128cc37f7
    61 
    61 
    62 class View(presence.View):
    62 class View(presence.View):
    63   """View methods for the Program model.
    63   """View methods for the Program model.
    64   """
    64   """
    65 
    65 
       
    66   DEF_ACCEPTED_ORGS_MSG_FMT = ugettext("These organizations have"
       
    67       " been accepted into %(name)s, but they have not yet completed"
       
    68       " their organization profile. You can still learn more about"
       
    69       " each organization by visiting the links below.")
       
    70 
       
    71   DEF_CREATED_ORGS_MSG_FMT = ugettext("These organizations have been"
       
    72       " accepted into %(name)s and have completed their organization"
       
    73       " profiles. You can learn more about each organization by"
       
    74       " visiting the links below.")
       
    75 
    66   def __init__(self, params=None):
    76   def __init__(self, params=None):
    67     """Defines the fields and methods required for the base View class
    77     """Defines the fields and methods required for the base View class
    68     to provide the user with list, public, create, edit and delete views.
    78     to provide the user with list, public, create, edit and delete views.
    69 
    79 
    70     Params:
    80     Params:
   187     contents = []
   197     contents = []
   188     logic = params['logic']
   198     logic = params['logic']
   189 
   199 
   190     program_entity = logic.getFromKeyFieldsOr404(kwargs)
   200     program_entity = logic.getFromKeyFieldsOr404(kwargs)
   191 
   201 
       
   202     fmt = {'name': program_entity.name}
       
   203     description = self.DEF_ACCEPTED_ORGS_MSG_FMT % fmt
       
   204 
   192     filter = {
   205     filter = {
   193         'status': 'accepted',
   206         'status': 'accepted',
   194         'scope': program_entity,
   207         'scope': program_entity,
   195         }
   208         }
   196 
   209 
   198     aa_params = org_app_view.view.getParams().copy() # accepted applications
   211     aa_params = org_app_view.view.getParams().copy() # accepted applications
   199 
   212 
   200     # define the list redirect action to show the notification
   213     # define the list redirect action to show the notification
   201     del aa_params['list_key_order']
   214     del aa_params['list_key_order']
   202     aa_params['list_action'] = (redirects.getPublicRedirect, aa_params)
   215     aa_params['list_action'] = (redirects.getPublicRedirect, aa_params)
   203     aa_params['list_description'] = ugettext(
   216     aa_params['list_description'] = description
   204         "An overview of accepted organization applications that have"
       
   205         " not yet created their organization profile. Students can"
       
   206         " only apply to organizations that created their organization"
       
   207         " profile.")
       
   208 
   217 
   209     aa_list = lists.getListContent(request, aa_params, filter, idx=0,
   218     aa_list = lists.getListContent(request, aa_params, filter, idx=0,
   210                                    need_content=True)
   219                                    need_content=True)
   211 
   220 
   212     if aa_list:
   221     if aa_list:
   213       contents.append(aa_list)
   222       contents.append(aa_list)
   214 
   223 
       
   224     description = self.DEF_CREATED_ORGS_MSG_FMT % fmt
       
   225 
   215     filter['status'] = ['new', 'active']
   226     filter['status'] = ['new', 'active']
   216 
   227 
   217     from soc.views.models import organization as org_view
   228     from soc.views.models import organization as org_view
   218     ao_params = org_view.view.getParams().copy() # active orgs
   229     ao_params = org_view.view.getParams().copy() # active orgs
   219 
   230 
   220     ao_params['list_action'] = (redirects.getPublicRedirect, ao_params)
   231     ao_params['list_action'] = (redirects.getPublicRedirect, ao_params)
   221     ao_params['list_description'] = ugettext(
   232     ao_params['list_description'] = description
   222         "An overview of all accepted organizations.")
       
   223 
   233 
   224     ao_list = lists.getListContent(request, ao_params, filter, idx=1)
   234     ao_list = lists.getListContent(request, ao_params, filter, idx=1)
   225     contents.append(ao_list)
   235     contents.append(ao_list)
   226 
   236 
   227     return self._list(request, params, contents, page_name)
   237     return self._list(request, params, contents, page_name)