Browse Source

Add admin model for allocation log

Baptiste Jonglez 10 years ago
parent
commit
0ff5842155
2 changed files with 17 additions and 1 deletions
  1. 14 1
      coin/resources/admin.py
  2. 3 0
      coin/resources/models.py

+ 14 - 1
coin/resources/admin.py

@@ -1,6 +1,6 @@
 from django.contrib import admin
 
-from coin.resources.models import IPPool, IPSubnet
+from coin.resources.models import IPPool, IPSubnet, IPAllocationLog
 
 admin.site.register(IPPool,)
 
@@ -8,3 +8,16 @@ admin.site.register(IPPool,)
 # creating/editing the object in the admin (since it is a purely
 # user-specific parameter)
 admin.site.register(IPSubnet,)
+
+
+class IPAllocationAdmin(admin.ModelAdmin):
+    list_display = ('subnet', 'user', 'subscription', 'offer', 'start_date',
+                    'stop_date')
+    list_filter = ('offer',)
+    search_fields = ('subnet', 'offer__name', 'offer__type',
+                     'user__first_name', 'user__last_name', 'user__email')
+    readonly_fields = ('subnet', 'user', 'subscription', 'offer', 'start_date',
+                       'stop_date')
+
+
+admin.site.register(IPAllocationLog, IPAllocationAdmin)

+ 3 - 0
coin/resources/models.py

@@ -131,6 +131,9 @@ class IPAllocationLog(models.Model):
     """
     # All we need to do is automatically fill this in upon other objects'
     # creation/destruction/deactivation.
+
+    # TODO: what do we do when a related object is modified?  For
+    # instance, a subscription gets transferred to a new user.
     subnet = CidrAddressField()
     user = models.ForeignKey('members.Member', null=True, blank=True,
                              on_delete=models.SET_NULL)