|
@@ -8,6 +8,8 @@ from django.db import models
|
|
|
from django.db.models import Count, Q
|
|
|
from django.core.validators import MinValueValidator
|
|
|
|
|
|
+from coin.resources.models import IPPool
|
|
|
+
|
|
|
|
|
|
class Offer(models.Model):
|
|
|
"""Description of an offer available to subscribers.
|
|
@@ -44,6 +46,8 @@ class Offer(models.Model):
|
|
|
verbose_name='n\'est pas facturable',
|
|
|
help_text='L\'offre ne sera pas facturée par la commande charge_members')
|
|
|
|
|
|
+ ippools = models.ManyToManyField(IPPool, through='OfferIPPool')
|
|
|
+
|
|
|
def get_configuration_type_display(self):
|
|
|
"""
|
|
|
Renvoi le nom affichable du type de configuration
|
|
@@ -79,6 +83,20 @@ class Offer(models.Model):
|
|
|
verbose_name = 'offre'
|
|
|
|
|
|
|
|
|
+class OfferIPPool(models.Model):
|
|
|
+ offer = models.ForeignKey(Offer,
|
|
|
+ verbose_name='offre')
|
|
|
+ ippool = models.ForeignKey(IPPool,
|
|
|
+ verbose_name='pool d\'IP')
|
|
|
+ to_assign = models.BooleanField(default=False,
|
|
|
+ verbose_name='assignation par défaut')
|
|
|
+
|
|
|
+ class Meta:
|
|
|
+ verbose_name = 'pool d\'IP'
|
|
|
+ verbose_name_plural = "pools d'IP"
|
|
|
+ ordering = ['-to_assign']
|
|
|
+
|
|
|
+
|
|
|
class OfferSubscriptionQuerySet(models.QuerySet):
|
|
|
def running(self, at_date=None):
|
|
|
""" Only the running contracts at a given date.
|