app/soc/views/site/sponsor/list.py
changeset 259 74eb6b01c82c
child 263 9b39d93b677f
equal deleted inserted replaced
258:12f4f7d16fac 259:74eb6b01c82c
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2008 the Melange authors.
       
     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 """Developer views for listing Sponsors profiles.
       
    18 """
       
    19 
       
    20 __authors__ = [
       
    21   '"Pawel Solyga" <pawel.solyga@gmail.com>',
       
    22   ]
       
    23 
       
    24 
       
    25 from soc.logic import sponsor
       
    26 from soc.views import simple
       
    27 from soc.views.helpers import list_helpers
       
    28 from soc.views.helpers import response_helpers
       
    29 
       
    30 
       
    31 DEF_SITE_SPONSOR_LIST_ALL_TMPL = 'soc/group/list/all.html'
       
    32 
       
    33 def all(request, template=DEF_SITE_SPONSOR_LIST_ALL_TMPL):
       
    34   """Show a list of all Sponsors (limit rows per page).
       
    35   """
       
    36   # create default template context for use with any templates
       
    37   context = response_helpers.getUniversalContext(request)
       
    38 
       
    39   alt_response = simple.getAltResponseIfNotDeveloper(request,
       
    40                                                      context=context)
       
    41   if alt_response:
       
    42     return alt_response  
       
    43   
       
    44   offset = request.GET.get('offset')
       
    45   limit = request.GET.get('limit')
       
    46 
       
    47   offset, limit = list_helpers.getListParemeters(offset, limit)
       
    48   
       
    49   sponsors = sponsor.getSponsorsForOffsetAndLimit(offset, limit)
       
    50   
       
    51   list_templates = {'list_main': 'soc/list/list_main.html',
       
    52                     'list_pagination': 'soc/list/list_pagination.html',
       
    53                     'list_row': 'soc/group/list/group_row.html',
       
    54                     'list_heading': 'soc/group/list/group_heading.html'}
       
    55                       
       
    56   context = list_helpers.setList(request, context, sponsors, 
       
    57                                  offset, limit, list_templates)
       
    58                                  
       
    59   context['group_type'] = 'Sponsor'
       
    60 
       
    61   return response_helpers.respond(request, template, context)