Commit 566649ab authored by Gabriel Detraz's avatar Gabriel Detraz Committed by chirac

Origin devient une foreignkey

parent 1f2a3364
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-04-09 20:43
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('machines', '0076_auto_20180130_1623'),
]
operations = [
migrations.AlterField(
model_name='extension',
name='origin',
field=models.ForeignKey(blank=True, help_text='Enregistrement A associé à la zone', null=True, on_delete=django.db.models.deletion.PROTECT, to='machines.IpList'),
),
]
......@@ -484,7 +484,7 @@ class Extension(RevMixin, AclMixin, models.Model):
help_text="Nom de la zone, doit commencer par un point (.example.org)"
)
need_infra = models.BooleanField(default=False)
origin = models.OneToOneField(
origin = models.ForeignKey(
'IpList',
on_delete=models.PROTECT,
blank=True,
......
......@@ -175,7 +175,7 @@ class ExtensionSerializer(serializers.ModelSerializer):
fields = ('name', 'origin', 'origin_v6', 'zone_entry', 'soa')
def get_origin_ip(self, obj):
return obj.origin.ipv4
return getattr(obj.origin, 'ipv4', None)
def get_zone_name(self, obj):
return str(obj.dns_entry)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment