mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
Origin devient une foreignkey
This commit is contained in:
parent
1f2a3364b3
commit
566649ab45
3 changed files with 23 additions and 2 deletions
21
machines/migrations/0077_auto_20180409_2243.py
Normal file
21
machines/migrations/0077_auto_20180409_2243.py
Normal 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'),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue