Пример #1
0
def asn_allocate_view(request, pk):
    log = request.META['wsgi.errors']
    handle = request.session['handle']
    obj = get_object_or_404(models.Asn.objects, pk=pk)
    # ensure this resource range belongs to a parent of the current conf
    parent_set = get_parents_or_404(handle, obj)

    if request.method == 'POST':
        form = forms.PrefixAllocateForm(None, handle.children.all(),
                                        request.POST)
        if form.is_valid():
            obj.allocated = form.cleaned_data['child']
            obj.save()
            glue.configure_resources(log, handle)
            return http.HttpResponseRedirect(obj.get_absolute_url())
    else:
        form = forms.PrefixAllocateForm(
            obj.allocated.pk if obj.allocated else None, handle.children.all())

    return render('rpkigui/asn_view.html', {
        'form': form,
        'asn': obj,
        'form': form,
        'parent': parent_set
    }, request)
Пример #2
0
 def handle_post(self):
     self.form = forms.PrefixAllocateForm(None, self.handle.children.all(), self.request.POST)
     if self.form.is_valid():
         self.obj.allocated = self.form.cleaned_data['child']
         self.obj.save()
         glue.configure_resources(self.request.META['wsgi.errors'], self.handle)
         return http.HttpResponseRedirect(self.obj.get_absolute_url())
Пример #3
0
 def handle_post(self):
     self.form = forms.PrefixAllocateForm(None, self.handle.children.all(),
                                          self.request.POST)
     if self.form.is_valid():
         self.obj.allocated = self.form.cleaned_data['child']
         self.obj.save()
         glue.configure_resources(self.request.META['wsgi.errors'],
                                  self.handle)
         return http.HttpResponseRedirect(self.obj.get_absolute_url())
Пример #4
0
def ghostbuster_delete(request, pk):
    conf = request.session['handle']

    # verify that the object is owned by this conf
    obj = get_object_or_404(models.Ghostbuster, pk=pk, conf=conf)

    # modeled loosely on the generic delete_object() view.
    if request.method == 'POST':
        obj.delete()
        glue.configure_resources(request.META['wsgi.errors'], conf)
        return http.HttpResponseRedirect(reverse(ghostbusters_list))
    else:
        return render('rpkigui/ghostbuster_confirm_delete.html', { 'object': obj }, request)
Пример #5
0
def ghostbuster_delete(request, pk):
    conf = request.session['handle']

    # verify that the object is owned by this conf
    obj = get_object_or_404(models.Ghostbuster, pk=pk, conf=conf)

    # modeled loosely on the generic delete_object() view.
    if request.method == 'POST':
        obj.delete()
        glue.configure_resources(request.META['wsgi.errors'], conf)
        return http.HttpResponseRedirect(reverse(ghostbusters_list))
    else:
        return render('rpkigui/ghostbuster_confirm_delete.html',
                      {'object': obj}, request)
Пример #6
0
def child_edit(request, child_handle):
    """Edit the end validity date for a resource handle's child."""
    handle = request.session['handle']
    child = get_object_or_404(handle.children, handle__exact=child_handle)

    if request.method == 'POST':
        form = forms.ChildForm(request.POST, request.FILES, instance=child)
        if form.is_valid():
            form.save()
            glue.configure_resources(request.META['wsgi.errors'], handle)
            return http.HttpResponseRedirect(child.get_absolute_url())
    else:
        form = forms.ChildForm(instance=child)
        
    return render('rpkigui/child_form.html', { 'child': child, 'form': form }, request)
Пример #7
0
def child_edit(request, child_handle):
    """Edit the end validity date for a resource handle's child."""
    handle = request.session['handle']
    child = get_object_or_404(handle.children, handle__exact=child_handle)

    if request.method == 'POST':
        form = forms.ChildForm(request.POST, request.FILES, instance=child)
        if form.is_valid():
            form.save()
            glue.configure_resources(request.META['wsgi.errors'], handle)
            return http.HttpResponseRedirect(child.get_absolute_url())
    else:
        form = forms.ChildForm(instance=child)

    return render('rpkigui/child_form.html', {
        'child': child,
        'form': form
    }, request)
Пример #8
0
def _ghostbuster_edit(request, obj=None):
    """
    Common code for create/edit.
    """
    conf = request.session['handle']
    form_class = forms.GhostbusterForm(conf.parents.all())
    if request.method == 'POST':
        form = form_class(request.POST, request.FILES, instance=obj)
        if form.is_valid():
            # use commit=False for the creation case, otherwise form.save()
            # will fail due to schema constraint violation because conf is
            # NULL
            obj = form.save(commit=False)
            obj.conf = conf
            obj.save()
            glue.configure_resources(request.META['wsgi.errors'], conf)
            return http.HttpResponseRedirect(obj.get_absolute_url())
    else:
        form = form_class(instance=obj)
    return render('rpkigui/ghostbuster_form.html', { 'form': form }, request)
Пример #9
0
def asn_allocate_view(request, pk):
    log = request.META['wsgi.errors']
    handle = request.session['handle']
    obj = get_object_or_404(models.Asn.objects, pk=pk)
    # ensure this resource range belongs to a parent of the current conf
    parent_set = get_parents_or_404(handle, obj)

    if request.method == 'POST':
        form = forms.PrefixAllocateForm(None, handle.children.all(), request.POST)
        if form.is_valid():
            obj.allocated = form.cleaned_data['child']
            obj.save()
            glue.configure_resources(log, handle)
            return http.HttpResponseRedirect(obj.get_absolute_url())
    else:
        form = forms.PrefixAllocateForm(obj.allocated.pk if obj.allocated else None,
                handle.children.all())

    return render('rpkigui/asn_view.html', { 'form': form,
        'asn': obj, 'form': form, 'parent': parent_set }, request)
Пример #10
0
def _ghostbuster_edit(request, obj=None):
    """
    Common code for create/edit.
    """
    conf = request.session['handle']
    form_class = forms.GhostbusterForm(conf.parents.all())
    if request.method == 'POST':
        form = form_class(request.POST, request.FILES, instance=obj)
        if form.is_valid():
            # use commit=False for the creation case, otherwise form.save()
            # will fail due to schema constraint violation because conf is
            # NULL
            obj = form.save(commit=False)
            obj.conf = conf
            obj.save()
            glue.configure_resources(request.META['wsgi.errors'], conf)
            return http.HttpResponseRedirect(obj.get_absolute_url())
    else:
        form = form_class(instance=obj)
    return render('rpkigui/ghostbuster_form.html', {'form': form}, request)
Пример #11
0
def roa_request_delete_view(request, pk):
    """
    Remove a ROA request from a particular prefix.
    """

    log = request.META['wsgi.errors']
    handle = request.session['handle']
    obj = get_object_or_404(models.RoaRequest.objects, pk=pk)
    prefix = obj.prefix
    # ensure this resource range belongs to a parent of the current conf
    parent_set = get_parents_or_404(handle, prefix)

    if request.method == 'POST':
        roa = obj.roa
        obj.delete()
        if not roa.from_roa_request.all():
            roa.delete()
        glue.configure_resources(log, handle)
        return http.HttpResponseRedirect(prefix.get_absolute_url())

    return render('rpkigui/roa_request_confirm_delete.html', { 'object': obj }, request)
Пример #12
0
def roa_request_delete_view(request, pk):
    """
    Remove a ROA request from a particular prefix.
    """

    log = request.META['wsgi.errors']
    handle = request.session['handle']
    obj = get_object_or_404(models.RoaRequest.objects, pk=pk)
    prefix = obj.prefix
    # ensure this resource range belongs to a parent of the current conf
    parent_set = get_parents_or_404(handle, prefix)

    if request.method == 'POST':
        roa = obj.roa
        obj.delete()
        if not roa.from_roa_request.all():
            roa.delete()
        glue.configure_resources(log, handle)
        return http.HttpResponseRedirect(prefix.get_absolute_url())

    return render('rpkigui/roa_request_confirm_delete.html', {'object': obj},
                  request)
Пример #13
0
 def form_valid(self):
     asns = asnset(self.form.cleaned_data['asns'])
     add_roa_requests(self.handle, self.obj, asns, self.form.cleaned_data['max_length'])
     glue.configure_resources(self.request.META['wsgi.errors'], self.handle)
     return http.HttpResponseRedirect(self.obj.get_absolute_url())
Пример #14
0
 def form_valid(self):
     asns = asnset(self.form.cleaned_data['asns'])
     add_roa_requests(self.handle, self.obj, asns,
                      self.form.cleaned_data['max_length'])
     glue.configure_resources(self.request.META['wsgi.errors'], self.handle)
     return http.HttpResponseRedirect(self.obj.get_absolute_url())