layerindex-web/layerindex/context_processors.py
Paul Eggleton af499c0d99 Add sort priority field to branch model
This enables sorting the branch drop-down in a configurable manner (e.g.
so that you can have them in order from newest to oldest).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2013-03-06 22:56:31 +00:00

17 lines
557 B
Python

# layerindex-web - custom context processor
#
# Copyright (C) 2013 Intel Corporation
#
# Licensed under the MIT license, see COPYING.MIT for details
from layerindex.models import Branch, LayerItem
def layerindex_context(request):
current_branch = request.session.get('branch', None)
if not current_branch:
current_branch = 'master'
return {
'all_branches': Branch.objects.all().order_by('sort_priority'),
'current_branch': current_branch,
'unpublished_count': LayerItem.objects.filter(status='N').count(),
}