8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 01:16:27 +00:00

Origin devient une foreignkey

This commit is contained in:
Gabriel Detraz 2018-04-09 22:49:44 +02:00 committed by chirac
parent 1f2a3364b3
commit 566649ab45
3 changed files with 23 additions and 2 deletions

View file

@ -0,0 +1,21 @@
# -*- 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'),
),
]

View file

@ -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,

View file

@ -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)