Add ability to hide branches

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-06-21 16:16:12 +12:00
parent dba1fbe5d1
commit bcedcb7006
4 changed files with 24 additions and 3 deletions

View File

@ -21,11 +21,11 @@ def layerindex_context(request):
else: else:
login_return_url = request.path login_return_url = request.path
return { return {
'all_branches': Branch.objects.exclude(comparison=True).order_by('sort_priority'), 'all_branches': Branch.objects.exclude(comparison=True).exclude(hidden=True).order_by('sort_priority'),
'unpublished_count': LayerItem.objects.filter(status='N').count(), 'unpublished_count': LayerItem.objects.filter(status='N').count(),
'site_name': site_name, 'site_name': site_name,
'rrs_enabled': 'rrs' in settings.INSTALLED_APPS, 'rrs_enabled': 'rrs' in settings.INSTALLED_APPS,
'notices': SiteNotice.objects.filter(disabled=False).filter(Q(expires__isnull=True) | Q(expires__gte=datetime.now())), 'notices': SiteNotice.objects.filter(disabled=False).filter(Q(expires__isnull=True) | Q(expires__gte=datetime.now())),
'comparison_branches': Branch.objects.filter(comparison=True), 'comparison_branches': Branch.objects.filter(comparison=True).exclude(hidden=True),
'login_return_url': login_return_url, 'login_return_url': login_return_url,
} }

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-06-21 05:15
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layerindex', '0027_patch_apply_order'),
]
operations = [
migrations.AddField(
model_name='branch',
name='hidden',
field=models.BooleanField(default=False, help_text='Hide from normal selections', verbose_name='Hidden'),
),
]

View File

@ -75,6 +75,7 @@ class Branch(models.Model):
updates_enabled = models.BooleanField('Enable updates', default=True, help_text='Enable automatically updating layer metadata for this branch via the update script') updates_enabled = models.BooleanField('Enable updates', default=True, help_text='Enable automatically updating layer metadata for this branch via the update script')
comparison = models.BooleanField('Comparison', default=False, help_text='If enabled, branch is for comparison purposes only and will appear separately') comparison = models.BooleanField('Comparison', default=False, help_text='If enabled, branch is for comparison purposes only and will appear separately')
update_environment = models.ForeignKey(PythonEnvironment, blank=True, null=True, on_delete=models.SET_NULL) update_environment = models.ForeignKey(PythonEnvironment, blank=True, null=True, on_delete=models.SET_NULL)
hidden = models.BooleanField('Hidden', default=False, help_text='Hide from normal selections')
updated = models.DateTimeField(auto_now=True, blank=True, null=True) updated = models.DateTimeField(auto_now=True, blank=True, null=True)

View File

@ -1369,7 +1369,7 @@ class StatsView(TemplateView):
context['class_count_distinct'] = BBClass.objects.values('name').distinct().count() context['class_count_distinct'] = BBClass.objects.values('name').distinct().count()
context['machine_count_distinct'] = Machine.objects.values('name').distinct().count() context['machine_count_distinct'] = Machine.objects.values('name').distinct().count()
context['distro_count_distinct'] = Distro.objects.values('name').distinct().count() context['distro_count_distinct'] = Distro.objects.values('name').distinct().count()
context['perbranch'] = Branch.objects.order_by('sort_priority').annotate( context['perbranch'] = Branch.objects.filter(hidden=False).order_by('sort_priority').annotate(
layer_count=Count('layerbranch', distinct=True), layer_count=Count('layerbranch', distinct=True),
recipe_count=Count('layerbranch__recipe', distinct=True), recipe_count=Count('layerbranch__recipe', distinct=True),
class_count=Count('layerbranch__bbclass', distinct=True), class_count=Count('layerbranch__bbclass', distinct=True),