Indicate if layer has YP Compatible certification
PATCH 1/1 Indicate if layer has YP Compatible certification
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]
--- 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(-)
layerindex/admin.py +9 -2
@@ -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)
layerindex/models.py +15 -0
@@ -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')
layerindex/static/css/additional.css +5 -0
@@ -232,3 +232,8 @@ blockquote.span7.warn { .valign-middle { vertical-align: middle; } + +.yp-icon { + width: auto; + height: 1em; +}
templates/layerindex/detail.html +3 -0
@@ -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 %}
templates/layerindex/layers.html +5 -1
@@ -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">
templates/layerindex/reviewdetail.html +3 -0
@@ -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 %}
templates/layerindex/reviewlist.html +5 -1
@@ -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">
Signature · 1 line
2.7.4
Quoted 3 lines · Amanda Brindle
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.
Who are the Admins ?
- armin
Quoted 171 lines
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 <[email protected]>--- 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(-)layerindex/admin.py +9
-2@@ -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)layerindex/models.py +15
-0@@ -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')layerindex/static/css/additional.css +5
-0@@ -232,3 +232,8 @@ blockquote.span7.warn { .valign-middle { vertical-align: middle; } + +.yp-icon { + width: auto; + height: 1em; +}templates/layerindex/detail.html +3
-0@@ -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 %}templates/layerindex/layers.html +5
-1@@ -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">templates/layerindex/reviewdetail.html +3
-0@@ -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 %}templates/layerindex/reviewlist.html +5
-1@@ -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">
Quoted 6 lines · NZDT akuster
Quoted 3 lines · Amanda Brindle
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.
Who are the Admins ?
As far as this patch is concerned, anyone who is a superuser or has the required permission.
For the OE layer index specifically - Michael Halstead, Mark Hatle and myself currently. It's most likely we will grant the permission to someone who is involved with maintaining the Yocto Project Compatible program that this links to and they'll be the one who manages these things.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Hi Amanda,
Quoted 4 lines · NZDT Amanda Brindle
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.
Quoted 8 lines
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]
I've merged this with a few minor changes:
* Renamed redirect_url to link_url as it seemed a bit more appropriate
* Fixed missing quotes around attribute values in the template
* Added a data migration
* Set a verbose_name for YPCompatibleVersion and LayerBranch.yp_compatible_version
(Hope this is OK - normally I would have asked for a v2, but we're approaching the deadline for M4).
Thanks,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre