app/soc/views/site/sponsor/list.py
changeset 294 1fdaab4a6ef2
parent 272 00cea07656c0
child 299 a1cc853a56e5
equal deleted inserted replaced
293:1edd01373e71 294:1fdaab4a6ef2
    21   '"Pawel Solyga" <pawel.solyga@gmail.com>',
    21   '"Pawel Solyga" <pawel.solyga@gmail.com>',
    22   ]
    22   ]
    23 
    23 
    24 
    24 
    25 from soc.logic import sponsor
    25 from soc.logic import sponsor
       
    26 from soc.logic.helper import access
    26 from soc.views import simple
    27 from soc.views import simple
    27 
       
    28 from soc.views import helper
    28 from soc.views import helper
    29 import soc.views.helper.lists
    29 import soc.views.helper.lists
    30 import soc.views.helper.responses
    30 import soc.views.helper.responses
    31 
    31 
    32 
    32 
    33 DEF_SITE_SPONSOR_LIST_ALL_TMPL = 'soc/group/list/all.html'
    33 DEF_SITE_SPONSOR_LIST_ALL_TMPL = 'soc/group/list/all.html'
    34 
    34 
    35 def all(request, template=DEF_SITE_SPONSOR_LIST_ALL_TMPL):
    35 def all(request, template=DEF_SITE_SPONSOR_LIST_ALL_TMPL):
    36   """Show a list of all Sponsors (limit rows per page).
    36   """Show a list of all Sponsors (limit rows per page).
    37   """
    37   """
       
    38 
       
    39   try:
       
    40     access.checkIsDeveloper(request)
       
    41   except  soc.logic.out_of_band.AccessViolationResponse, alt_response:
       
    42     return alt_response.response()
       
    43 
    38   # create default template context for use with any templates
    44   # create default template context for use with any templates
    39   context = helper.responses.getUniversalContext(request)
    45   context = helper.responses.getUniversalContext(request)
    40 
    46 
    41   alt_response = simple.getAltResponseIfNotDeveloper(request,
       
    42                                                      context=context)
       
    43   if alt_response:
       
    44     return alt_response  
       
    45   
       
    46   offset, limit = helper.lists.cleanListParameters(
    47   offset, limit = helper.lists.cleanListParameters(
    47       offset=request.GET.get('offset'), limit=request.GET.get('limit'))
    48       offset=request.GET.get('offset'), limit=request.GET.get('limit'))
    48   
    49   
    49   # Fetch one more to see if there should be a 'next' link
    50   # Fetch one more to see if there should be a 'next' link
    50   sponsors = sponsor.getSponsorsForLimitAndOffset(limit + 1, offset=offset)
    51   sponsors = sponsor.getSponsorsForLimitAndOffset(limit + 1, offset=offset)