[yocto] [layerindex][PATCH] Indicate if layer has YP Compatible certification
Amanda Brindle
amanda.r.brindle at intel.com
Mon Sep 25 16:41:32 PDT 2017
Allow admin to create Yocto Project versions with the version name,
description, an icon link that represents that version, and a link that
contains more information about the version.
Admins who have the "set_yp_compatibility" permission can then
decide if a layer has Yocto Project compatible certification,
and if it does, admin can choose which version of Yocto Project
the layer is compatible with. If a layer is deemed compatible,
the version's icon will appear next to the layer's name, and
the icon will redirect to the link with more information.
Fixes [YOCTO #11452]
Signed-off-by: Amanda Brindle <amanda.r.brindle at intel.com>
---
layerindex/admin.py | 11 +++++++++--
layerindex/models.py | 15 +++++++++++++++
layerindex/static/css/additional.css | 5 +++++
templates/layerindex/detail.html | 3 +++
templates/layerindex/layers.html | 6 +++++-
templates/layerindex/reviewdetail.html | 3 +++
templates/layerindex/reviewlist.html | 6 +++++-
7 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/layerindex/admin.py b/layerindex/admin.py
index d25829a..a7d024b 100644
--- a/layerindex/admin.py
+++ b/layerindex/admin.py
@@ -44,6 +44,9 @@ class BranchAdmin(CompareVersionAdmin):
layerdependency.save()
duplicate.short_description = "Duplicate selected Branches"
+class YPCompatibleVersionAdmin(CompareVersionAdmin):
+ pass
+
class LayerItemAdmin(CompareVersionAdmin):
list_filter = ['status', 'layer_type']
save_as = True
@@ -61,9 +64,12 @@ class LayerBranchAdmin(CompareVersionAdmin):
LayerMaintainerInline,
]
def get_readonly_fields(self, request, obj=None):
+ readonly_fields = self.readonly_fields
if obj:
- return self.readonly_fields + ('layer', 'branch')
- return self.readonly_fields
+ readonly_fields += ('layer', 'branch')
+ if not request.user.has_perm('layerindex.set_yp_compatibility'):
+ readonly_fields += ('yp_compatible_version',)
+ return readonly_fields
class LayerMaintainerAdmin(CompareVersionAdmin):
list_filter = ['status', 'layerbranch__layer__name']
@@ -145,6 +151,7 @@ class RecipeChangesetAdmin(admin.ModelAdmin):
]
admin.site.register(Branch, BranchAdmin)
+admin.site.register(YPCompatibleVersion, YPCompatibleVersionAdmin)
admin.site.register(LayerItem, LayerItemAdmin)
admin.site.register(LayerBranch, LayerBranchAdmin)
admin.site.register(LayerMaintainer, LayerMaintainerAdmin)
diff --git a/layerindex/models.py b/layerindex/models.py
index fb2e026..2297152 100644
--- a/layerindex/models.py
+++ b/layerindex/models.py
@@ -141,6 +141,17 @@ class LayerItem(models.Model):
def __str__(self):
return self.name
+class YPCompatibleVersion(models.Model):
+ name = models.CharField('Yocto Project Version', max_length=25, unique=True, help_text='Name of this Yocto Project compatible version (e.g. "2.0")')
+ description = models.TextField(blank=True)
+ image_url = models.CharField('Image URL', max_length=300, blank=True)
+ redirect_url = models.CharField('Redirection URL', max_length=100, blank=True)
+
+ class Meta:
+ ordering = ('name',)
+
+ def __str__(self):
+ return self.name
class LayerBranch(models.Model):
layer = models.ForeignKey(LayerItem)
@@ -152,11 +163,15 @@ class LayerBranch(models.Model):
vcs_last_rev = models.CharField('Last revision fetched', max_length=80, blank=True)
vcs_last_commit = models.DateTimeField('Last commit date', blank=True, null=True)
actual_branch = models.CharField('Actual Branch', max_length=80, blank=True, help_text='Name of the actual branch in the repository matching the core branch')
+ yp_compatible_version = models.ForeignKey(YPCompatibleVersion, null=True, blank=True, on_delete=models.SET_NULL, help_text='Which version of the Yocto Project Compatible program has this layer been approved for for?')
updated = models.DateTimeField(auto_now=True)
class Meta:
verbose_name_plural = "Layer branches"
+ permissions = (
+ ("set_yp_compatibility", "Can set YP compatibility"),
+ )
def sorted_recipes(self):
return self.recipe_set.order_by('pn', '-pv')
diff --git a/layerindex/static/css/additional.css b/layerindex/static/css/additional.css
index 2a27712..324ee34 100644
--- a/layerindex/static/css/additional.css
+++ b/layerindex/static/css/additional.css
@@ -232,3 +232,8 @@ blockquote.span7.warn {
.valign-middle {
vertical-align: middle;
}
+
+.yp-icon {
+ width: auto;
+ height: 1em;
+}
diff --git a/templates/layerindex/detail.html b/templates/layerindex/detail.html
index 4f1b333..f721096 100644
--- a/templates/layerindex/detail.html
+++ b/templates/layerindex/detail.html
@@ -30,6 +30,9 @@
<div class="row-fluid">
<div class="page-header">
<h1>{{ layeritem.name }}
+ {% if layerbranch.yp_compatible_version %}
+ <a href={{layerbranch.yp_compatible_version.redirect_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 %}
{% if layeritem.status = "N" %}
<span class="label label-warning">Unpublished</span>
{% endif %}
diff --git a/templates/layerindex/layers.html b/templates/layerindex/layers.html
index b11ff2f..4d0d127 100644
--- a/templates/layerindex/layers.html
+++ b/templates/layerindex/layers.html
@@ -72,7 +72,11 @@
<tbody>
{% 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></td>
+ <td><a href="{% url 'layer_item' url_branch layerbranch.layer.name %}">{{ layerbranch.layer.name }}</a>
+ {% if layerbranch.yp_compatible_version %}
+ <a href={{layerbranch.yp_compatible_version.redirect_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 %}
+ </td>
<td>{{ layerbranch.layer.summary }}</td>
<td>{{ layerbranch.layer.get_layer_type_display }}</td>
<td class="showRollie">
diff --git a/templates/layerindex/reviewdetail.html b/templates/layerindex/reviewdetail.html
index cff1731..e188632 100644
--- a/templates/layerindex/reviewdetail.html
+++ b/templates/layerindex/reviewdetail.html
@@ -27,6 +27,9 @@
<div class="row-fluid">
<div class="page-header">
<h1>{{ layeritem.name }}
+ {% if layerbranch.yp_compatible_version %}
+ <a href={{layerbranch.yp_compatible_version.redirect_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 %}
{% if layeritem.status = "N" %}
<span class="label label-warning">Unpublished</span>
{% else %}
diff --git a/templates/layerindex/reviewlist.html b/templates/layerindex/reviewlist.html
index eaa24e4..0bc0602 100644
--- a/templates/layerindex/reviewlist.html
+++ b/templates/layerindex/reviewlist.html
@@ -36,7 +36,11 @@
<tbody>
{% for layerbranch in layerbranch_list %}
<tr class="layertype_{{ layerbranch.layer.layer_type }}">
- <td><a href="{% url 'layer_review' layerbranch.layer.name %}">{{ layerbranch.layer.name }}</a></td>
+ <td><a href="{% url 'layer_review' layerbranch.layer.name %}">{{ layerbranch.layer.name }}</a>
+ {% if layerbranch.yp_compatible_version %}
+ <a href={{layerbranch.yp_compatible_version.redirect_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 %}
+ </td>
<td>{{ layerbranch.layer.summary }}</td>
<td>{{ layerbranch.layer.get_layer_type_display }}</td>
<td class="showRollie">
--
2.7.4
More information about the yocto
mailing list