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:
Fabian Faessler 2013-09-29 17:43:17 +02:00
parent 2aff509334
commit 8e66e702f7
2 changed files with 12 additions and 9 deletions

View File

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

View File

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