layerindex: add "No update" status to LayerItem

Add a status for a layer indicating it should not be updated. I don't
expect this to be widely used (and is only settable from the admin
interface) but would be useful if you have a legacy sub-layer that you
want to prevent from being visible on certain branches - it will prevent
the update script from doing anything with the layer and thus avoid
branch records from being auto-created on branches where you've deleted
it.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2017-03-09 08:48:01 +13:00
parent 2919424f89
commit 51614fe5a0
6 changed files with 27 additions and 6 deletions

View File

@ -179,7 +179,7 @@ class AdvancedRecipeSearchForm(forms.Form):
field = forms.ChoiceField(choices=FIELD_CHOICES)
match_type = forms.ChoiceField(choices=MATCH_TYPE_CHOICES)
value = forms.CharField(max_length=255, required=False)
layer = forms.ModelChoiceField(queryset=LayerItem.objects.filter(classic=False).filter(status='P').order_by('name'), empty_label="(any)", required=False)
layer = forms.ModelChoiceField(queryset=LayerItem.objects.filter(classic=False).filter(status__in=['P', 'X']).order_by('name'), empty_label="(any)", required=False)
class RecipeChangesetForm(forms.ModelForm):

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layerindex', '0006_change_branch_meta'),
]
operations = [
migrations.AlterField(
model_name='layeritem',
name='status',
field=models.CharField(default='N', choices=[('N', 'New'), ('P', 'Published'), ('X', 'No update')], max_length=1),
),
]

View File

@ -65,6 +65,7 @@ class LayerItem(models.Model):
LAYER_STATUS_CHOICES = (
('N', 'New'),
('P', 'Published'),
('X', 'No update'),
)
LAYER_TYPE_CHOICES = (
('A', 'Base'),

View File

@ -22,7 +22,7 @@ class LayerItemSerializer(serializers.ModelSerializer):
model = LayerItem
class LayerItemViewSet(ParametricSearchableModelViewSet):
queryset = LayerItem.objects.filter(status='P')
queryset = LayerItem.objects.filter(status__in=['P', 'X'])
serializer_class = LayerItemSerializer
class LayerBranchSerializer(serializers.ModelSerializer):
@ -30,7 +30,7 @@ class LayerBranchSerializer(serializers.ModelSerializer):
model = LayerBranch
class LayerBranchViewSet(ParametricSearchableModelViewSet):
queryset = LayerBranch.objects.filter(layer__status='P')
queryset = LayerBranch.objects.filter(layer__status__in=['P', 'X'])
serializer_class = LayerBranchSerializer
class LayerDependencySerializer(serializers.ModelSerializer):
@ -38,7 +38,7 @@ class LayerDependencySerializer(serializers.ModelSerializer):
model = LayerDependency
class LayerDependencyViewSet(ParametricSearchableModelViewSet):
queryset = LayerDependency.objects.filter(layerbranch__layer__status='P')
queryset = LayerDependency.objects.filter(layerbranch__layer__status__in=['P', 'X'])
serializer_class = LayerDependencySerializer
class RecipeSerializer(serializers.ModelSerializer):

View File

@ -157,6 +157,7 @@ def main():
logger.error('No layers matching specified query "%s"' % options.layers)
sys.exit(1)
else:
# We deliberately exclude status == 'X' ("no update") here
layerquery = LayerItem.objects.filter(classic=False).filter(status='P')
if layerquery.count() == 0:
logger.info("No published layers to update")

View File

@ -279,7 +279,7 @@ class LayerListView(ListView):
def get_queryset(self):
_check_url_branch(self.kwargs)
return LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status='P').order_by('layer__layer_type', '-layer__index_preference', 'layer__name')
return LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status__in=['P', 'X']).order_by('layer__layer_type', '-layer__index_preference', 'layer__name')
def get_context_data(self, **kwargs):
context = super(LayerListView, self).get_context_data(**kwargs)
@ -459,7 +459,7 @@ class DuplicatesView(TemplateView):
context['classes'] = self.get_classes(layer_ids)
context['url_branch'] = self.kwargs['branch']
context['this_url_name'] = resolve(self.request.path_info).url_name
context['layers'] = LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status='P').order_by( 'layer__name')
context['layers'] = LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status__in=['P', 'X']).order_by( 'layer__name')
context['showlayers'] = layer_ids
return context