changes
This commit is contained in:
parent
a28d6ac963
commit
b94f9d8afd
|
@ -1,27 +1,46 @@
|
|||
from django.db import models
|
||||
from base import BaseModel
|
||||
from settings import SERVER_CHOICES, EMAIL_CHOICES, DB_CHOICES, PROJECT_TYPES
|
||||
from base.models import BaseModel
|
||||
from settings import EMAIL_CHOICES, DB_CHOICES, PROJECT_TYPES, REGISTRAR_CHOICES
|
||||
|
||||
|
||||
|
||||
class DomainBase(BaseModel):
|
||||
url = models.CharField(max_length=512)
|
||||
server = models.CharField(choices=SERVER_CHOICES, blank=True, max_length=128)
|
||||
email = models.CharField(choices=EMAIL_CHOICES, blank=True)
|
||||
url = models.CharField(max_length=512, unique=True)
|
||||
server = models.ForeignKey("Server", blank=True, null=True, max_length=128)
|
||||
email = models.CharField(max_length=64, choices=EMAIL_CHOICES, blank=True)
|
||||
path = models.CharField(max_length=255, blank=True)
|
||||
project_type = models.CharField(choices=PROJECT_TYPES, blank=True)
|
||||
db_type = models.CharField(choices=DB_CHOICES, blank=True)
|
||||
project_type = models.CharField(max_length=64, choices=PROJECT_TYPES, blank=True)
|
||||
db_type = models.CharField(max_length=64, choices=DB_CHOICES, blank=True)
|
||||
db_name = models.CharField(max_length=255, blank=True)
|
||||
is_active = models.BooleanField(default=1)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
ordering = ['url']
|
||||
|
||||
def __unicode__(self):
|
||||
return self.url
|
||||
|
||||
|
||||
class Domain(DomainBase):
|
||||
pass
|
||||
manage_nameserver = models.BooleanField(default=False)
|
||||
domain_registrar = models.CharField(max_length=128, choices=REGISTRAR_CHOICES)
|
||||
|
||||
|
||||
class Subdomain(DomainBase):
|
||||
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.
|
||||
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',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
'django.contrib.admindocs',
|
||||
'django_extensions',
|
||||
'base',
|
||||
'domain'
|
||||
)
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
|
@ -153,11 +156,6 @@ LOGGING = {
|
|||
|
||||
#Project specific settings:
|
||||
|
||||
SERVER_CHOICES = (
|
||||
('camp', 'camp.r-w-x.org'),
|
||||
('marlon', 'marlon.in'),
|
||||
)
|
||||
|
||||
EMAIL_CHOICES = (
|
||||
('gmail', 'Gmail'),
|
||||
('mailb', 'MailB'),
|
||||
|
@ -174,6 +172,11 @@ PROJECT_TYPES = (
|
|||
('www', 'PHP or Static'),
|
||||
)
|
||||
|
||||
REGISTRAR_CHOICES = (
|
||||
('unknown', 'Unknown'),
|
||||
('net4', 'Net 4 India'),
|
||||
('iwantmyname', 'I Want My Name'),
|
||||
)
|
||||
|
||||
#overwrite default settings with local settings
|
||||
try:
|
||||
|
|
|
@ -13,6 +13,8 @@ urlpatterns = patterns('',
|
|||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
# 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)),
|
||||
)
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Django>=1.4
|
||||
ox
|
||||
django_extensions
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user