changes
This commit is contained in:
parent
a28d6ac963
commit
b94f9d8afd
|
@ -1,27 +1,46 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from base import BaseModel
|
from base.models import BaseModel
|
||||||
from settings import SERVER_CHOICES, EMAIL_CHOICES, DB_CHOICES, PROJECT_TYPES
|
from settings import EMAIL_CHOICES, DB_CHOICES, PROJECT_TYPES, REGISTRAR_CHOICES
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DomainBase(BaseModel):
|
class DomainBase(BaseModel):
|
||||||
url = models.CharField(max_length=512)
|
url = models.CharField(max_length=512, unique=True)
|
||||||
server = models.CharField(choices=SERVER_CHOICES, blank=True, max_length=128)
|
server = models.ForeignKey("Server", blank=True, null=True, max_length=128)
|
||||||
email = models.CharField(choices=EMAIL_CHOICES, blank=True)
|
email = models.CharField(max_length=64, choices=EMAIL_CHOICES, blank=True)
|
||||||
path = models.CharField(max_length=255, blank=True)
|
path = models.CharField(max_length=255, blank=True)
|
||||||
project_type = models.CharField(choices=PROJECT_TYPES, blank=True)
|
project_type = models.CharField(max_length=64, choices=PROJECT_TYPES, blank=True)
|
||||||
db_type = models.CharField(choices=DB_CHOICES, blank=True)
|
db_type = models.CharField(max_length=64, choices=DB_CHOICES, blank=True)
|
||||||
db_name = models.CharField(max_length=255, blank=True)
|
db_name = models.CharField(max_length=255, blank=True)
|
||||||
|
is_active = models.BooleanField(default=1)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
ordering = ['url']
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.url
|
return self.url
|
||||||
|
|
||||||
|
|
||||||
class Domain(DomainBase):
|
class Domain(DomainBase):
|
||||||
pass
|
manage_nameserver = models.BooleanField(default=False)
|
||||||
|
domain_registrar = models.CharField(max_length=128, choices=REGISTRAR_CHOICES)
|
||||||
|
|
||||||
|
|
||||||
class Subdomain(DomainBase):
|
class Subdomain(DomainBase):
|
||||||
main_domain = models.ForeignKey(Domain)
|
main_domain = models.ForeignKey(Domain)
|
||||||
|
|
||||||
|
class DomainAlias(BaseModel):
|
||||||
|
alias = models.CharField(max_length=512)
|
||||||
|
domain = models.ForeignKey(Domain)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.alias
|
||||||
|
|
||||||
|
class Server(BaseModel):
|
||||||
|
hostname = models.CharField(max_length=32)
|
||||||
|
ip_address = models.IPAddressField()
|
||||||
|
reverse_lookup = models.CharField(max_length=255, blank=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return "%s" % (self.hostname,)
|
||||||
|
|
|
@ -1 +1,27 @@
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
from models import *
|
||||||
|
from django.shortcuts import render_to_response
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
|
||||||
|
def named_masters(request):
|
||||||
|
domains = [d.url for d in Domain.objects.filter(is_active=True).filter(manage_nameserver=True)]
|
||||||
|
domains += [d.alias for d in DomainAlias.objects.all()]
|
||||||
|
domains.sort()
|
||||||
|
context = {
|
||||||
|
'domains': domains
|
||||||
|
}
|
||||||
|
content = render_to_string("named.conf.masters", context)
|
||||||
|
return HttpResponse(content, content_type="text/plain")
|
||||||
|
|
||||||
|
|
||||||
|
def named_slaves(request):
|
||||||
|
domains = [d.url for d in Domain.objects.filter(is_active=True).filter(manage_nameserver=True)]
|
||||||
|
domains += [d.alias for d in DomainAlias.objects.all()]
|
||||||
|
domains.sort()
|
||||||
|
context = {
|
||||||
|
'domains': domains
|
||||||
|
}
|
||||||
|
content = render_to_string("named.conf.slaves", context)
|
||||||
|
return HttpResponse(content, content_type="text/plain")
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,9 @@ INSTALLED_APPS = (
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
# Uncomment the next line to enable admin documentation:
|
# Uncomment the next line to enable admin documentation:
|
||||||
'django.contrib.admindocs',
|
'django.contrib.admindocs',
|
||||||
|
'django_extensions',
|
||||||
|
'base',
|
||||||
|
'domain'
|
||||||
)
|
)
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
# A sample logging configuration. The only tangible logging
|
||||||
|
@ -153,11 +156,6 @@ LOGGING = {
|
||||||
|
|
||||||
#Project specific settings:
|
#Project specific settings:
|
||||||
|
|
||||||
SERVER_CHOICES = (
|
|
||||||
('camp', 'camp.r-w-x.org'),
|
|
||||||
('marlon', 'marlon.in'),
|
|
||||||
)
|
|
||||||
|
|
||||||
EMAIL_CHOICES = (
|
EMAIL_CHOICES = (
|
||||||
('gmail', 'Gmail'),
|
('gmail', 'Gmail'),
|
||||||
('mailb', 'MailB'),
|
('mailb', 'MailB'),
|
||||||
|
@ -174,6 +172,11 @@ PROJECT_TYPES = (
|
||||||
('www', 'PHP or Static'),
|
('www', 'PHP or Static'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
REGISTRAR_CHOICES = (
|
||||||
|
('unknown', 'Unknown'),
|
||||||
|
('net4', 'Net 4 India'),
|
||||||
|
('iwantmyname', 'I Want My Name'),
|
||||||
|
)
|
||||||
|
|
||||||
#overwrite default settings with local settings
|
#overwrite default settings with local settings
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -13,6 +13,8 @@ urlpatterns = patterns('',
|
||||||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
|
|
||||||
# Uncomment the next line to enable the admin:
|
# Uncomment the next line to enable the admin:
|
||||||
|
url(r'^dns/named.conf.masters$', 'domain.views.named_masters', name="named_masters"),
|
||||||
|
url(r'^dns/named.conf.slaves$', 'domain.views.named_slaves', name="named_slaves"),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
Django>=1.4
|
Django>=1.4
|
||||||
ox
|
ox
|
||||||
|
django_extensions
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user