added get_fqdn() method to Host model. added post_save signal to delete dns entry when Host object is deleted
This commit is contained in:
parent
2aff509334
commit
8e66e702f7
@ -3,6 +3,8 @@ from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import RegexValidator
|
||||
from django.conf import settings
|
||||
from django.db.models.signals import post_save
|
||||
from main import dnstools
|
||||
|
||||
import re
|
||||
|
||||
@ -63,3 +65,13 @@ class Host(models.Model):
|
||||
|
||||
class Meta:
|
||||
unique_together = (('subdomain', 'domain'),)
|
||||
|
||||
def get_fqdn(self):
|
||||
return self.subdomain.self.domain.domain
|
||||
|
||||
|
||||
def post_delete_host(sender, **kwargs):
|
||||
obj = kwargs['instance']
|
||||
dnstools.delete(obj.get_fqdn())
|
||||
|
||||
post_save.connect(post_delete_host, sender=Host)
|
||||
|
@ -49,15 +49,6 @@ class HelpView(TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
class AboutView(TemplateView):
|
||||
template_name = "main/about.html"
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super(AboutView, self).get_context_data(*args, **kwargs)
|
||||
context['nav_about'] = True
|
||||
return context
|
||||
|
||||
|
||||
class OverviewView(CreateView):
|
||||
model = Host
|
||||
template_name = "main/overview.html"
|
||||
|
Loading…
x
Reference in New Issue
Block a user