mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 12:49:01 +02:00

Add the ability to show a notice at the top of every page; this provides the ability for admins to display a message to visitors in the case of infrastructure or index data issues. Notices can have an expiry date and can be disabled and re-enabled if needed. A subset of HTML can be used for formatting the text, URLs will be made into clickable links, and four "levels" are supported (info, success, warning and error). Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
27 lines
1.0 KiB
Python
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(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,
|
|
'rrs_enabled': 'rrs' in settings.INSTALLED_APPS,
|
|
'notices': SiteNotice.objects.filter(disabled=False).filter(Q(expires__isnull=True) | Q(expires__gte=datetime.now())),
|
|
}
|