admin of UsableResource, allow charge parent to be null, tabular display of charge
smbaker [Fri, 1 Mar 2013 03:56:34 +0000 (19:56 -0800)]
apps/billingsystem/billing/admin.py
apps/billingsystem/billing/models.py

index 93bb767..30a3611 100644 (file)
@@ -1,5 +1,5 @@
 from django.contrib import admin
-from billing.models import Account, Charge, ChargeKind, ChargeState
+from billing.models import Account, Charge, ChargeKind, ChargeState, UsableResource
 
 class AccountAdmin(admin.ModelAdmin):
     search_fields = ['name']
@@ -7,6 +7,7 @@ class AccountAdmin(admin.ModelAdmin):
 
 class ChargeAdmin(admin.ModelAdmin):
     date_hierarchy = 'date'
+    list_display = ('pk', 'account', 'object', 'parent', 'kind', 'state', 'date', 'amount', 'coreHours')
 
 class ChargeKindAdmin(admin.ModelAdmin):
     list_display = ('pk', 'name')
@@ -14,7 +15,11 @@ class ChargeKindAdmin(admin.ModelAdmin):
 class ChargeStateAdmin(admin.ModelAdmin):
     list_display = ('pk', 'name')
 
+class UsableResourceAdmin(admin.ModelAdmin):
+    list_display = ('pk', 'name')
+
 admin.site.register(Account, AccountAdmin)
 admin.site.register(Charge, ChargeAdmin)
 admin.site.register(ChargeKind, ChargeKindAdmin)
 admin.site.register(ChargeState, ChargeStateAdmin)
+admin.site.register(UsableResource, UsableResourceAdmin)
index 30b88f2..081ede0 100644 (file)
@@ -63,12 +63,14 @@ class ChargeState(models.Model):
 class Charge(models.Model):
     account = models.ForeignKey(Account)
     object = models.ForeignKey(UsableResource)
-    parent = models.ForeignKey('self', blank=True, related_name="children")
+    parent = models.ForeignKey('self', blank=True, null=True, related_name="children")
     kind = models.ForeignKey(ChargeKind)
     state = models.ForeignKey(ChargeState)
     date = models.DateTimeField()
     amount = models.FloatField(default=0.0)
     coreHours = models.FloatField(default=0.0)
+    def __unicode__(self):
+        return unicode(self.pk)