From fcb44571fd387c72cbc193b9ef6ef0433c264829 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Fri, 12 Jan 2018 11:06:08 +1300 Subject: [PATCH] Add "needs attention" flag for comparison recipes Add a flag that can be set and searched for to indicate that we need to take care of importing a package or a patch applied by a package. Ideally the comments would elaborate on what's needed (if it's not obvious from the cover status). Signed-off-by: Paul Eggleton --- layerindex/forms.py | 8 +++++++- .../0017_classicrecipe_needs_attention.py | 19 +++++++++++++++++++ layerindex/models.py | 1 + layerindex/views.py | 6 ++++++ templates/layerindex/classicrecipedetail.html | 8 +++++++- templates/layerindex/classicrecipes.html | 12 ++---------- 6 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 layerindex/migrations/0017_classicrecipe_needs_attention.py diff --git a/layerindex/forms.py b/layerindex/forms.py index 77c30de..bc0df9d 100644 --- a/layerindex/forms.py +++ b/layerindex/forms.py @@ -164,7 +164,7 @@ class EditProfileForm(forms.ModelForm): class ClassicRecipeForm(forms.ModelForm): class Meta: model = ClassicRecipe - fields = ('cover_layerbranch', 'cover_pn', 'cover_status', 'cover_verified', 'cover_comment', 'classic_category') + fields = ('cover_layerbranch', 'cover_pn', 'cover_status', 'cover_verified', 'cover_comment', 'classic_category', 'needs_attention') def clean(self): cleaned_data = super(ClassicRecipeForm, self).clean() @@ -226,6 +226,11 @@ class ClassicRecipeSearchForm(forms.Form): ('1', 'Has patches'), ('0', 'No patches'), ] + ATTENTION_CHOICES = [ + ('', '(any)'), + ('1', 'Yes'), + ('0', 'No'), + ] q = forms.CharField(label='Keyword', max_length=255, required=False) category = forms.CharField(max_length=255, required=False) @@ -233,4 +238,5 @@ class ClassicRecipeSearchForm(forms.Form): has_patches = forms.ChoiceField(label='Patches', choices=PATCH_CHOICES, required=False) cover_status = forms.ChoiceField(label='Status', choices=COVER_STATUS_CHOICES, required=False) cover_verified = forms.ChoiceField(label='Verified', choices=VERIFIED_CHOICES, required=False) + needs_attention = forms.ChoiceField(label='Needs attention', choices=ATTENTION_CHOICES, required=False) diff --git a/layerindex/migrations/0017_classicrecipe_needs_attention.py b/layerindex/migrations/0017_classicrecipe_needs_attention.py new file mode 100644 index 0000000..6d9d209 --- /dev/null +++ b/layerindex/migrations/0017_classicrecipe_needs_attention.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('layerindex', '0016_classicrecipe_delete'), + ] + + operations = [ + migrations.AddField( + model_name='classicrecipe', + name='needs_attention', + field=models.BooleanField(default=False), + ), + ] diff --git a/layerindex/models.py b/layerindex/models.py index e9bf27f..b4fe549 100644 --- a/layerindex/models.py +++ b/layerindex/models.py @@ -535,6 +535,7 @@ class ClassicRecipe(Recipe): cover_comment = models.TextField(blank=True) classic_category = models.CharField('OE-Classic Category', max_length=100, blank=True) deleted = models.BooleanField(default=False) + needs_attention = models.BooleanField(default=False) class Meta: permissions = ( diff --git a/layerindex/views.py b/layerindex/views.py index 554fbf6..d67cb74 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -929,6 +929,7 @@ class ClassicRecipeSearchView(RecipeSearchView): category = self.request.GET.get('category', None) oe_layer = self.request.GET.get('oe_layer', None) has_patches = self.request.GET.get('has_patches', '') + needs_attention = self.request.GET.get('needs_attention', '') init_qs = ClassicRecipe.objects.filter(layerbranch__branch__name=self.kwargs['branch']).filter(deleted=False) if cover_status: if cover_status == '!': @@ -951,6 +952,11 @@ class ClassicRecipeSearchView(RecipeSearchView): init_qs = init_qs.filter(patch__isnull=False).distinct() else: init_qs = init_qs.filter(patch__isnull=True) + if needs_attention.strip(): + if needs_attention == '1': + init_qs = init_qs.filter(needs_attention=True) + else: + init_qs = init_qs.filter(needs_attention=False) if query_string.strip(): order_by = (Lower('pn'), 'layerbranch__layer') diff --git a/templates/layerindex/classicrecipedetail.html b/templates/layerindex/classicrecipedetail.html index d1c5366..ff8a458 100644 --- a/templates/layerindex/classicrecipedetail.html +++ b/templates/layerindex/classicrecipedetail.html @@ -141,8 +141,14 @@ +

+

+ +

{% else %} diff --git a/templates/layerindex/classicrecipes.html b/templates/layerindex/classicrecipes.html index c766806..e476aaa 100644 --- a/templates/layerindex/classicrecipes.html +++ b/templates/layerindex/classicrecipes.html @@ -96,11 +96,7 @@ {% for recipe in recipe_list %} 0 %}class="muted"{% endif %}> {% if compare %} - {% if branch.name == 'oe-classic' %} - {{ recipe.name }} - {% else %} - {{ recipe.name }} - {% endif %} + {{ recipe.name }}{% if recipe.needs_attention %} {% endif %} {{ recipe.pv|truncatechars:10 }} {% if recipe.patch_set.exists %}{{ recipe.patch_set.count }}{% endif %} {{ recipe.get_cover_status_display }}{% if recipe.cover_comment %} {% endif %} @@ -115,11 +111,7 @@ {% endif %} {% else %} - {% if branch.name == 'oe-classic' %} - {{ recipe.name }} - {% else %} - {{ recipe.name }} - {% endif %} + {{ recipe.name }}{% if recipe.needs_attention %} {% endif %} {{ recipe.pv }} {{ recipe.short_desc }} {{ recipe.get_cover_desc }}