|
@@ -1,4 +1,6 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
+import datetime
|
|
|
+
|
|
|
from django.db import models
|
|
|
from django.core.exceptions import ValidationError
|
|
|
from django.core.validators import MaxValueValidator
|
|
@@ -107,3 +109,39 @@ class IPSubnet(models.Model):
|
|
|
|
|
|
def __unicode__(self):
|
|
|
return str(self.inet)
|
|
|
+
|
|
|
+
|
|
|
+class IPAllocationLog(models.Model):
|
|
|
+ """Tracks IP allocation for users/subscribers. Data retention laws
|
|
|
+ generally impose two distincts things:
|
|
|
+
|
|
|
+ 1/ Keep the data for a given duration
|
|
|
+
|
|
|
+ 2/ Delete the data after this duration is expired
|
|
|
+
|
|
|
+ Besides data retention, we may also want to have an history of our IP
|
|
|
+ subnets.
|
|
|
+
|
|
|
+ The idea of this model is that log entries are kept forever. However,
|
|
|
+ as old users and subscriptions get deleted over time, the log entries
|
|
|
+ will contain less and less information. Eventually, we will just know
|
|
|
+ things like "such subnet was used at such time", without any idea on
|
|
|
+ who the user was.
|
|
|
+
|
|
|
+ """
|
|
|
+ # All we need to do is automatically fill this in upon other objects'
|
|
|
+ # creation/destruction/deactivation.
|
|
|
+ subnet = CidrAddressField(unique=True)
|
|
|
+ user = models.ForeignKey('members.Member', null=True, blank=True,
|
|
|
+ on_delete=models.SET_NULL)
|
|
|
+ subscription = models.ForeignKey('offers.OfferSubscription', null=True,
|
|
|
+ blank=True, on_delete=models.SET_NULL)
|
|
|
+ offer = models.ForeignKey('offers.Offer', null=True, blank=True,
|
|
|
+ on_delete=models.SET_NULL)
|
|
|
+ start_date = models.DateField(default=datetime.date.today)
|
|
|
+ stop_date = models.DateField(null=True, blank=True)
|
|
|
+
|
|
|
+ objects = NetManager()
|
|
|
+
|
|
|
+ def __unicode__(self):
|
|
|
+ return str(self.subnet)
|