def destroy_handle(request, handle): """ Completely remove a hosted resource handle. """ log = request.META['wsgi.errors'] if not request.user.is_superuser: return http.HttpResponseForbidden() conf = get_object_or_404(models.Conf, handle=handle) if request.method == 'POST': form = forms.GenericConfirmationForm(request.POST, request.FILES) if form.is_valid(): glue.destroy_handle(log, handle) return render('rpkigui/generic_result.html', { 'operation': 'Destroy ' + handle, 'result': 'Succeeded' }, request) else: form = forms.GenericConfirmationForm() return render('rpkigui/destroy_handle_form.html', { 'form': form, 'handle': handle }, request)
def update_bpki(request): conf = request.session['handle'] log = request.META['wsgi.errors'] if request.method == 'POST': form = forms.GenericConfirmationForm(request.POST, request.FILES) if form.is_valid(): glue.update_bpki(log, conf) return http.HttpResponseRedirect(reverse(dashboard)) else: form = forms.GenericConfirmationForm() return render('rpkigui/update_bpki_form.html', {'form': form}, request)
def initialize(request): """ Initialize a new user account. """ if request.method == 'POST': form = forms.GenericConfirmationForm(request.POST) if form.is_valid(): glue.initialize_handle(request.META['wsgi.errors'], handle=request.user.username, owner=request.user) return http.HttpResponseRedirect(reverse(dashboard)) else: form = forms.GenericConfirmationForm() return render('rpkigui/initialize_form.html', {'form': form}, request)
def child_delete(request, child_handle): conf = request.session['handle'] log = request.META['wsgi.errors'] child = get_object_or_404(conf.children, handle__exact=child_handle) if request.method == 'POST': form = forms.GenericConfirmationForm(request.POST, request.FILES) if form.is_valid(): glue.delete_child(log, conf, child_handle) child.delete() return http.HttpResponseRedirect(reverse(dashboard)) else: form = forms.GenericConfirmationForm() return render('rpkigui/child_delete_form.html', { 'form': form, 'object': child }, request)
def parent_delete(request, parent_handle): conf = request.session['handle'] log = request.META['wsgi.errors'] parent = get_object_or_404(conf.parents, handle__exact=parent_handle) if request.method == 'POST': form = forms.GenericConfirmationForm(request.POST, request.FILES) if form.is_valid(): glue.delete_parent(log, conf, parent_handle) parent.delete() return http.HttpResponseRedirect(reverse(dashboard)) else: form = forms.GenericConfirmationForm() return render('rpkigui/parent_form.html', { 'form': form, 'parent': parent, 'submit_label': 'Delete' }, request)