コード例 #1
0
ファイル: production_tags.py プロジェクト: rdavydov/demozoo
def carousel(context, production):
	carousel_items = get_carousel_items(production)
	screenshots = [i for i in carousel_items if i['type'] == 'screenshot']
	if screenshots:
		initial_screenshot = screenshots[0]
	else:
		initial_screenshot = None

	show_all_screenshots_link = len(screenshots) > 1
	if context['site_is_writeable']:
		show_add_screenshot_link = production.can_have_screenshots and carousel_items
		show_manage_screenshots_link = (production.can_have_screenshots or len(screenshots) > 1) and context['user'].is_staff
	else:
		show_add_screenshot_link = False
		show_manage_screenshots_link = False

	return {
		'production': production,
		'site_is_writeable': context['site_is_writeable'],
		'user': context['user'],

		'initial_screenshot': initial_screenshot,
		'show_all_screenshots_link': show_all_screenshots_link,
		'show_add_screenshot_link': show_add_screenshot_link,
		'show_manage_screenshots_link': show_manage_screenshots_link,
		'carousel_data': json.dumps(carousel_items),
	}
コード例 #2
0
ファイル: production_tags.py プロジェクト: rdavydov/demozoo
def carousel(context, production):
    carousel_items = get_carousel_items(production)
    screenshots = [i for i in carousel_items if i['type'] == 'screenshot']
    if screenshots:
        initial_screenshot = screenshots[0]
    else:
        initial_screenshot = None

    show_all_screenshots_link = len(screenshots) > 1
    if context['site_is_writeable']:
        show_add_screenshot_link = production.can_have_screenshots and carousel_items
        show_manage_screenshots_link = (
            production.can_have_screenshots
            or len(screenshots) > 1) and context['user'].is_staff
    else:
        show_add_screenshot_link = False
        show_manage_screenshots_link = False

    return {
        'production': production,
        'site_is_writeable': context['site_is_writeable'],
        'user': context['user'],
        'initial_screenshot': initial_screenshot,
        'show_all_screenshots_link': show_all_screenshots_link,
        'show_add_screenshot_link': show_add_screenshot_link,
        'show_manage_screenshots_link': show_manage_screenshots_link,
        'carousel_data': json.dumps(carousel_items),
    }
コード例 #3
0
ファイル: productions.py プロジェクト: rdavydov/demozoo
def carousel(request, production_id):
	production = get_object_or_404(Production, id=production_id)
	carousel_json = json.dumps(get_carousel_items(production))
	return HttpResponse(carousel_json, content_type='text/javascript')
コード例 #4
0
def carousel(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    carousel_json = json.dumps(get_carousel_items(production))
    return HttpResponse(carousel_json, content_type='text/javascript')