# -*- coding: utf-8 -*-
from django.db import models
from netfields import CidrAddressField, NetManager


class IPPool(models.Model):
    """Pool of IP addresses (either v4 or v6)."""
    name = models.CharField(max_length=255, blank=False, null=False,
                            verbose_name='Name of the IP pool')
    description = models.TextField(blank=True, null=False,
                                   verbose_name='Description of the IP pool')
    inet = CidrAddressField()
    objects = NetManager()

    def __unicode__(self):
        return self.name


class IPSubnet(models.Model):
    inet = CidrAddressField()
    objects = NetManager()
    ip_pool = models.ForeignKey(IPPool)
    offer_subscription = models.ForeignKey('offers.OfferSubscription',
                                           related_name='ip_subnet')

    def __unicode__(self):
        return str(self.inet)
