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

If you clicked on logout in the admin site then clicked on the "Login" button and logged in, you were redirected to the logout page because we weren't detecting that the redirection should not be applied. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
32 lines
1.3 KiB
Python
32 lines
1.3 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'
|
|
if request.path.startswith('/accounts') or request.path.startswith('/admin/logout'):
|
|
login_return_url = ''
|
|
else:
|
|
login_return_url = request.path
|
|
return {
|
|
'all_branches': Branch.objects.exclude(comparison=True).exclude(hidden=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).exclude(hidden=True),
|
|
'login_return_url': login_return_url,
|
|
}
|