Skip to contentSkip to conversation

layerindex: show when a layer branch is no longer updated

PATCH New Tim Orling 1 participant 1 message Nov 14

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

PATCH v2 1/1 layerindex: show when a layer branch is no longer updated

Updates can be turned off for a layer, a branch or a layer branch, but only the admin interface showed it, so the layer list and layer pages gave no hint that the information may be out of date. Show a "not updated" label with the reason next to the layer in the layer list and on the layer page.

[YOCTO #14781]

AI-Generated: Claude Opus 5.5

---
v2: use a lighter grey for the "not updated" label (light grey with dark grey text instead of Bootstrap's label-default), which was too bold with 171 of them in the master layer list. The label keeps label-default, so a browser with an older copy of additional.css still shows it.

 layerindex/models.py                 | 11 +++++++
 layerindex/static/css/additional.css |  8 +++++
 layerindex/views.py                  |  2 +-
 templates/layerindex/detail.html     |  7 +++++
 templates/layerindex/layers.html     |  1 +
 tests/test_updates_disabled.py       | 45 ++++++++++++++++++++++++++++
 6 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 tests/test_updates_disabled.py
layerindex/models.py +11 -0
index 1d72c55..d071788 100644
@@ -334,6 +334,17 @@ class LayerBranch(models.Model):
     def test_file_url(self):
         return self.file_url('conf/layer.conf')
 
+    def updates_disabled_reason(self):
+        """Why the update script no longer updates this layer branch, if it
+        doesn't"""
+        if self.layer.status == 'X':
+            return 'Updates are disabled for this layer'
+        if not self.branch.updates_enabled:
+            return 'Updates are disabled for the %s branch' % self.branch.name
+        if not self.updates_enabled:
+            return 'Updates are disabled for this layer on the %s branch' % self.branch.name
+        return ''
+
     def get_checkout_branch(self):
         """Get the branch that we actually need to check out in the repo"""
         if self.actual_branch:
layerindex/static/css/additional.css +8 -0
index a3c0a3a..dcab5cd 100644
@@ -321,3 +321,11 @@ td.info {
     height: 400px;
     overflow-y: scroll;
 }
+
+/* "not updated" label: lighter than label-default, still readable. It also
+   has label-default, so a browser with an older copy of this file still
+   shows it. */
+.label-default.label-not-updated {
+    background-color: #e8e8e8;
+    color: #555;
+}
layerindex/views.py +1 -1
index 592311f..85c82d6 100644
@@ -443,7 +443,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__in=['P', 'X']).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']).select_related('branch').order_by('layer__layer_type', '-layer__index_preference', 'layer__name')
 
     def get_context_data(self, **kwargs):
         context = super(LayerListView, self).get_context_data(**kwargs)
templates/layerindex/detail.html +7 -0
index 6c20f47..b14d030 100644
@@ -125,6 +125,13 @@
                     <span class="text-muted"><small>Last commit: {{ layerbranch.vcs_last_commit|timesince }} ago ({{ layerbranch.get_checkout_branch }} branch)</small></span>
                     </p>
                     {% endif %}
+                    {% with reason=layerbranch.updates_disabled_reason %}
+                    {% if reason %}
+                    <p>
+                    <span class="label label-default label-not-updated">not updated</span> <small class="text-muted">{{ reason }}, so the information here may be out of date.</small>
+                    </p>
+                    {% endif %}
+                    {% endwith %}
 
                     {% if layerbranch.active_maintainers.count > 0 %}
                     <h3>{% if layerbranch.active_maintainers|length == 1 %}Maintainer{% else %}Maintainers{% endif %}</h3>
templates/layerindex/layers.html +1 -0
index daae8cb..fb07d90 100644
@@ -75,6 +75,7 @@
                     {% for layerbranch in layerbranch_list %}
                     <tr class="layertype_{{ layerbranch.layer.layer_type }}">
                         <td><a href="{% url 'layer_item' url_branch layerbranch.layer.name %}">{{ layerbranch.layer.name }}</a>
+                            {% with reason=layerbranch.updates_disabled_reason %}{% if reason %}<span class="label label-default label-not-updated" title="{{ reason }}">not updated</span>{% endif %}{% endwith %}
                             {% if layerbranch.yp_compatible_version %}
                             <a href="{{layerbranch.yp_compatible_version.link_url}}"><img src="{{layerbranch.yp_compatible_version.image_url}}" alt="{{layerbranch.yp_compatible_version.description}}" class="yp-icon" title="{{layerbranch.yp_compatible_version.description}}" ></a>
                             {% endif %}
tests/test_updates_disabled.py new file +45 -0

45 lines not on this page · raw message

base-commit: 08e58cdece30019a6f9e5d14af16ebe20afa6177

Signature · 1 line
2.56.0