mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-28 01:43:46 +00:00
Merge branch 'tld_string' into 'dev'
Fonctions machines pour récup les tld en string , mise en cache See merge request federez/re2o!222
This commit is contained in:
commit
c0cc3e6240
1 changed files with 22 additions and 0 deletions
|
@ -36,6 +36,7 @@ import hashlib
|
|||
import base64
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
from django.dispatch import receiver
|
||||
from django.forms import ValidationError
|
||||
|
@ -194,6 +195,27 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
|
|||
"que les vôtres")
|
||||
return True, None
|
||||
|
||||
@cached_property
|
||||
def short_name(self):
|
||||
"""Par defaut, renvoie le nom de la première interface
|
||||
de cette machine"""
|
||||
return str(self.interface_set.first().domain.name)
|
||||
|
||||
@cached_property
|
||||
def all_short_names(self):
|
||||
"""Renvoie de manière unique, le nom des interfaces de cette
|
||||
machine"""
|
||||
return Domain.objects.filter(
|
||||
interface_parent__machine=self
|
||||
).values_list('name', flat=True).distinct()
|
||||
|
||||
@cached_property
|
||||
def all_complete_names(self):
|
||||
"""Renvoie tous les tls complets de la machine"""
|
||||
return [str(domain) for domain in Domain.objects.filter(
|
||||
Q(cname__interface_parent__machine=self) | Q(interface_parent__machine=self)
|
||||
)]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Machine, self).__init__(*args, **kwargs)
|
||||
self.field_permissions = {
|
||||
|
|
Loading…
Reference in a new issue