Exemple #1
0
def create_zone(request):
    template_zone = request.GET.get('template_zone', '').strip('"')

    context = None
    message = ''
    zones = get_zones()
    if template_zone:
        try:
            root_domain = zones.get(name=template_zone)
            context = {
                'message': 'Using {0} as a template.'.format(template_zone),
                'root_domain': root_domain.name,
                'contact': root_domain.soa.contact,
                'primary': root_domain.soa.primary,
                'nss': root_domain.nameserver_set.all(),
                'zones': json.dumps(
                    sorted([z.name for z in get_zones()], reverse=True))
            }
        except ObjectDoesNotExist:
            message = (
                "When trying to use {0} as a template, no zone "
                "named {0} was found.".format(template_zone)
            )
    if not context:
        context = {
            'message': message,
            'root_domain': '',
            'contact': '',
            'primary': '',
            'nss': [],
            'zones': json.dumps(
                sorted([z.name for z in get_zones()], reverse=True))
        }

    return render(request, 'create_zone/create_zone.html', context)
def delete_zone(request):
    domain_name = request.GET.get('domain_name', '')
    zones = get_zones().values_list('name', flat=True)
    return render(request, 'delete_zone/delete_zone.html', {
        'domain_name': domain_name,
        'zones': json.dumps(list(zones))
    })
def search(request):
    """Search page"""
    search = request.GET.get('search', '')
    return render(request, "search/core_search.html", {
        "search": search,
        "zones": sorted([z.name for z in get_zones()], reverse=True)
    })
Exemple #4
0
def search(request):
    """Search page"""
    search = request.GET.get('search', '')
    return render(request, "search/core_search.html", {
        "search": search,
        "zones": sorted([z.name for z in get_zones()], reverse=True)
    })
Exemple #5
0
def create_zone(request):
    template_zone = request.GET.get('template_zone', '').strip('"')

    context = None
    message = ''
    zones = get_zones()
    if template_zone:
        try:
            root_domain = zones.get(name=template_zone)
            context = {
                'message':
                'Using {0} as a template.'.format(template_zone),
                'root_domain':
                root_domain.name,
                'contact':
                root_domain.soa.contact,
                'primary':
                root_domain.soa.primary,
                'nss':
                root_domain.nameserver_set.all(),
                'zones':
                json.dumps(sorted([z.name for z in get_zones()], reverse=True))
            }
        except ObjectDoesNotExist:
            message = ("When trying to use {0} as a template, no zone "
                       "named {0} was found.".format(template_zone))
    if not context:
        context = {
            'message':
            message,
            'root_domain':
            '',
            'contact':
            '',
            'primary':
            '',
            'nss': [],
            'zones':
            json.dumps(sorted([z.name for z in get_zones()], reverse=True))
        }

    return render(request, 'create_zone/create_zone.html', context)
def get_zones_json(request):
    return HttpResponse(json.dumps([z.name for z in get_zones()]))
Exemple #7
0
def get_zones_json(request):
    return HttpResponse(json.dumps([z.name for z in get_zones()]))