layerindex-web/layerindex/context_processors.py
Paul Eggleton 72d67231ec Add support for other distro comparisons
Turn the existing OE-Classic support into something a bit more
generic so we can import data from other distributions and compare it to
what we have in layers.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-07 14:44:27 +02:00

27 lines
1.0 KiB
Python

# layerindex-web - custom context processor
#
# Copyright (C) 2013, 2018 Intel Corporation
#
# Licensed under the MIT license, see COPYING.MIT for details
from layerindex.models import Branch, LayerItem, SiteNotice
from django.contrib.sites.models import Site
from django.db.models import Q
from datetime import datetime
def layerindex_context(request):
import settings
site = Site.objects.get_current()
if site and site.name and site.name != 'example.com':
site_name = site.name
else:
site_name = 'OpenEmbedded Layer Index'
return {
'all_branches': Branch.objects.exclude(comparison=True).order_by('sort_priority'),
'unpublished_count': LayerItem.objects.filter(status='N').count(),
'site_name': site_name,
'rrs_enabled': 'rrs' in settings.INSTALLED_APPS,
'notices': SiteNotice.objects.filter(disabled=False).filter(Q(expires__isnull=True) | Q(expires__gte=datetime.now())),
'comparison_branches': Branch.objects.filter(comparison=True),
}