make bucket a separate object
smbaker [Fri, 1 Mar 2013 17:09:21 +0000 (09:09 -0800)]
apps/billingsystem/billing/models.py
apps/billingsystem/billingsystem/settings.py
apps/billingsystem/datamodel.png [new file with mode: 0644]

index 081ede0..a90e715 100644 (file)
@@ -28,7 +28,6 @@ class BillingContact(models.Model):
     def __unicode__(self):
         return self.email
 
-
 class Account(models.Model):
     name = models.CharField(max_length=255)
     serviceLevel = models.ForeignKey(ServiceLevel)
@@ -39,12 +38,17 @@ class Account(models.Model):
     autoRenew = models.BooleanField(default=True)
     serviceStartDate = models.DateTimeField()
     balance = models.FloatField(default=0.0)
-    # for the bucket
-    bucketBalance = models.IntegerField(default=0)
-    lastInTime = models.DateTimeField(blank=True, null=True)
     def __unicode__(self):
         return self.name
 
+class Bucket(models.Model):
+    account = models.ForeignKey(Account)
+    resource = models.ForeignKey(Resource)
+    balance = models.IntegerField(default=0)
+    lastInTime = models.DateTimeField(blank=True, null=True)
+    def __unicode__(self):
+        return unicode(self.pk)
+
 class UsableResource(models.Model):
     name = models.CharField(max_length=255)
     def __unicode__(self):
index 00d335e..cb4da63 100644 (file)
@@ -125,6 +125,7 @@ INSTALLED_APPS = (
     # Uncomment the next line to enable admin documentation:
     # 'django.contrib.admindocs',
     'billing',
+    'django_extensions',
 )
 
 # A sample logging configuration. The only tangible logging
diff --git a/apps/billingsystem/datamodel.png b/apps/billingsystem/datamodel.png
new file mode 100644 (file)
index 0000000..7fe3a16
Binary files /dev/null and b/apps/billingsystem/datamodel.png differ