aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-04-18 08:57:12 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commitc183b360ff07673f00d0f4f224ced3c46fd87381 (patch)
tree471a1ce32ad8c0778058a915dfd0758b72dc8b3d /layerindex
parent9ebc94a1df62f3d91ba8ef1160daeee529ee0c83 (diff)
downloadopenembedded-core-contrib-c183b360ff07673f00d0f4f224ced3c46fd87381.tar.gz
admin: use more dynamic method of setting recipe read-only fields
Every time we add something that links to Recipe we had to add it to the exclusions list in the readonly_fields line for RecipeAdmin (and ClassicRecipeAdmin), which is tedious and easily forgotten. We can avoid this by looking at each field and excluding it by its attributes rather than having a hardcoded list of names. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex')
-rw-r--r--layerindex/admin.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/layerindex/admin.py b/layerindex/admin.py
index 7e93674ade..aed9a5d961 100644
--- a/layerindex/admin.py
+++ b/layerindex/admin.py
@@ -89,7 +89,12 @@ class LayerUpdateAdmin(admin.ModelAdmin):
class RecipeAdmin(admin.ModelAdmin):
search_fields = ['filename', 'pn']
list_filter = ['layerbranch__layer__name', 'layerbranch__branch__name']
- readonly_fields = [f.name for f in Recipe._meta.get_fields() if f.name not in ['recipefiledependency', 'classicrecipe', 'packageconfig']]
+ def get_readonly_fields(self, request, obj=None):
+ rofields = []
+ for f in Recipe._meta.get_fields():
+ if not (f.auto_created and f.is_relation):
+ rofields.append(f.name)
+ return rofields
def has_add_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
@@ -110,7 +115,12 @@ class DynamicBuildDepAdmin(admin.ModelAdmin):
class ClassicRecipeAdmin(admin.ModelAdmin):
search_fields = ['filename', 'pn']
list_filter = ['layerbranch__layer__name', 'layerbranch__branch__name']
- readonly_fields = [f.name for f in ClassicRecipe._meta.get_fields() if f.name not in ['recipefiledependency', 'packageconfig']]
+ def get_readonly_fields(self, request, obj=None):
+ rofields = []
+ for f in ClassicRecipe._meta.get_fields():
+ if not (f.auto_created and f.is_relation):
+ rofields.append(f.name)
+ return rofields
def has_add_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):