def save(self, *args, **kwargs): self.full_clean() update_range_usage = kwargs.pop('update_range_usage', True) old_range = None if self.id is not None: old_ip = AddressRecord.objects.get(id=self.id).ip_str old_range = find_range(old_ip) super(AddressRecord, self).save(*args, **kwargs) rng = find_range(self.ip_str) if rng and update_range_usage: rng.save(commit=False) if old_range: old_range.save(commit=False)
def grab_url(value): try: if type(value) in [str, unicode]: from cyder.cydhcp.range.utils import find_range value = find_range(value) return value.get_detail_url() except (AttributeError, ValueError): return None
def delete(self, *args, **kwargs): update_range_usage = kwargs.pop('update_range_usage', True) if self.reverse_domain.soa: self.reverse_domain.soa.schedule_rebuild() rng = find_range(self.ip_str) super(PTR, self).delete(*args, **kwargs) if rng and update_range_usage: rng.save(commit=False)
def save(self, *args, **kwargs): self.full_clean() update_range_usage = kwargs.pop('update_range_usage', True) old_range = None if self.id is not None: old_ip = PTR.objects.get(id=self.id).ip_str old_range = find_range(old_ip) super(PTR, self).save(*args, **kwargs) self.schedule_zone_rebuild() rng = self.range if rng and update_range_usage: rng.save(commit=False) if old_range: old_range.save(commit=False)
def range(self): if self.ip_str: return find_range(self.ip_str)
def delete(self, *args, **kwargs): update_range_usage = kwargs.pop('update_range_usage', True) rng = find_range(self.ip_str) super(AddressRecord, self).delete(*args, **kwargs) if rng and update_range_usage: rng.save(commit=False)
def range(self): rng = find_range(self.ip_str) return rng