layerindex-web/layerindex/context_processors.py
Aníbal Limón cf5fc3580b layerindex: Add support for rrs in settings.py and urls.py
settings.py: Add APPLICATION variable to switch between layerindex
rrs also add context_processors decision layerindex or rrs.

urls.py: Add decision for load urls for layerindex or rrs.

layerindex/context_processors.py: Add application variable for use
templates.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
2015-07-14 10:51:38 -05:00

24 lines
807 B
Python

# layerindex-web - custom context processor
#
# Copyright (C) 2013 Intel Corporation
#
# Licensed under the MIT license, see COPYING.MIT for details
import settings
from layerindex.models import Branch, LayerItem
from django.contrib.sites.models import Site
def layerindex_context(request):
site = Site.objects.get_current()
if site and site.name and site.name != 'example.com':
site_name = site.name
else:
site_name = 'OpenEmbedded metadata index'
return {
'all_branches': Branch.objects.exclude(name='oe-classic').order_by('sort_priority'),
'unpublished_count': LayerItem.objects.filter(status='N').count(),
'oe_classic': Branch.objects.filter(name='oe-classic'),
'site_name': site_name,
'application' : settings.APPLICATION
}