[MobLab] Add/Edit/Delete host attributes through AFE admin interface.

MobLab needs to use host attributes to specify Servo and Wificells.

Add an inline table when editing host through AFE admin interface.
Also grant permission to add/edit/delete host attributes to users through
db migration.

BUG=chromium:389659
TEST=ran afe, add/edit/delete host attributes
DEPLOY=migrate,apache

Change-Id: I13004481fd7b378b856dfbbad5ed9195603f83f6
Reviewed-on: https://chromium-review.googlesource.com/206142
Tested-by: Jiaxi Luo <jiaxiluo@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Jiaxi Luo <jiaxiluo@chromium.org>
diff --git a/frontend/afe/admin.py b/frontend/afe/admin.py
index fdd3958..8bf4c60 100644
--- a/frontend/afe/admin.py
+++ b/frontend/afe/admin.py
@@ -139,6 +139,11 @@
         model = models.Host
 
 
+class HostAttributeInline(admin.TabularInline):
+    model = models.HostAttribute
+    extra = 1
+
+
 class HostAdmin(SiteAdmin):
     # TODO(showard) - showing platform requires a SQL query for
     # each row (since labels are many-to-many) - should we remove
@@ -156,6 +161,10 @@
     def change_view(self, request, obj_id, form_url='', extra_context=None):
         # Hide labels_autodetection when editing a host.
         self.fields = ('hostname', 'locked', 'leased', 'protection', 'labels')
+        # Only allow editing host attributes when a host has been created.
+        self.inlines = [
+            HostAttributeInline,
+        ]
         return super(HostAdmin, self).change_view(request,
                                                   obj_id,
                                                   form_url,
@@ -209,7 +218,7 @@
 
     def save_related(self, request, form, formsets, change):
         """Save many-to-many relations between host and labels."""
-        # Skip save_related if autodetection succeeded, subce cli has already
+        # Skip save_related if autodetection succeeded, since cli has already
         # handled many-to-many relations.
         if not self.successful_hosts:
             super(HostAdmin, self).save_related(request,