misc: use "synchronous" as context key to request synchronous rendering (#8108)

This commit is contained in:
Frédéric Péters 2015-08-24 14:59:46 +02:00
parent be513d2166
commit cfbf3bf6a7
5 changed files with 10 additions and 9 deletions

View File

@ -45,6 +45,7 @@ def get_page_dict(request, page):
if cells:
context = RequestContext(request, {
'synchronous': True,
'page': page,
'page_cells': cells,
'request': request,

View File

@ -183,7 +183,7 @@ class WcsBlurpMixin(object):
'ajax': False,
})
if not context.get('ajax') and not renderer.has_cached_content(context):
if not context.get('synchronous') and not renderer.has_cached_content(context):
raise NothingInCacheException()
return renderer

View File

@ -488,7 +488,7 @@ class FeedCell(CellBase):
def render(self, context):
cache_key = hashlib.md5(self.url).hexdigest()
feed_content = cache.get(cache_key)
if not context.get('ajax') and feed_content is None:
if not context.get('synchronous') and feed_content is None:
raise NothingInCacheException()
if not feed_content:
feed_response = requests.get(self.url)

View File

@ -67,7 +67,7 @@ def ajax_page_cell(request, page_pk, cell_reference):
context = RequestContext(request, {
'page': page,
'request': request,
'ajax': True,
'synchronous': True,
'site_base': request.build_absolute_uri('/')[:-1],
})

View File

@ -244,7 +244,7 @@ def test_current_forms_cell_render():
result = cell.render(Context())
context = Context()
context['ajax'] = True # to get fresh content
context['synchronous'] = True # to get fresh content
result = cell.render(context)
assert not 'http://127.0.0.1:8999/form-title/' in result # no form
@ -288,13 +288,13 @@ def test_forms_of_category_cell_render():
cell.category_reference = 'default:test-9'
cell.ordering = 'alpha'
cell.save()
result = cell.render(Context({'ajax': True}))
result = cell.render(Context({'synchronous': True}))
assert 'form title' in result and 'a second form title' in result
assert result.index('form title') > result.index('a second form title')
cell.ordering = 'popularity'
cell.save()
result = cell.render(Context({'ajax': True}))
result = cell.render(Context({'synchronous': True}))
assert 'form title' in result and 'a second form title' in result
assert result.index('form title') < result.index('a second form title')
@ -304,13 +304,13 @@ def test_current_drafts_cell_render():
page.save()
cell = WcsCurrentDraftsCell(page=page, placeholder='content', order=0)
cell.save()
result = cell.render(Context({'ajax': True}))
result = cell.render(Context({'synchronous': True}))
assert not 'http://127.0.0.1:8999/third-form-title' in result # no form
context = Context({'ajax': True})
context = Context({'synchronous': True})
class MockUser(object):
email = 'foo@example.net'
context['user'] = MockUser()
context['ajax'] = True # to force fresh content
context['synchronous'] = True # to force fresh content
# default is to get current forms from all wcs sites
result = cell.render(context)