예제 #1
0
def network(request):
    logger = logging.getLogger(__name__)
    extra_context = {'wizard_title': u'2 de 4 - Configuração de Rede',
                     'page_name': u'network'}
    if request.method == "GET":
        interface = NetworkInterface.get_instance()
        Form = form(NetworkInterface)
        extra_context['form'] = Form(instance=interface)
        return render_to_response( request, "generic.html", extra_context)
    else:
        edit_singleton_model(request, "generic.html",
                             "nimbus.wizard.views.timezone",
                              model = NetworkInterface,
                              extra_context = extra_context)

        interface = NetworkInterface.get_instance()


        if interface.address == get_raw_network_interface_address():
            return redirect( "nimbus.wizard.views.timezone" )
        else:
            logger.info('redirecting user to redirect page')
            return render_to_response(request, "redirect.html", 
                                        dict(ip_address=interface.address,
                                             url=reverse('nimbus.wizard.views.timezone')))
예제 #2
0
def network(request):
    logger = logging.getLogger(__name__)
    extra_context = {
        'wizard_title': u'2 de 5 - Configuração de Rede',
        'page_name': u'network'
    }
    if request.method == "GET":
        interface = NetworkInterface.get_instance()
        Form = form(NetworkInterface)
        extra_context['form'] = Form(instance=interface)
        return render_to_response(request, "generic.html", extra_context)
    else:
        edit_singleton_model(request,
                             "generic.html",
                             next_step_url('network'),
                             model=NetworkInterface,
                             extra_context=extra_context)

        interface = NetworkInterface.get_instance()

        if interface.address == get_raw_network_interface_address():
            return redirect_next_step('network')
        else:
            logger.info('redirecting user to redirect page')
            return render_to_response(
                request, "redirect.html",
                dict(ip_address=interface.address,
                     url=next_step_url('network')))
예제 #3
0
def edit_singleton_model(request,
                         templatename,
                         redirect_to,
                         formclass=None,
                         model=None,
                         extra_context=None,
                         reload_bacula=True):

    if not '/' in redirect_to:
        redirect_to = reverse(redirect_to)

    if not formclass and model:
        formclass = forms.form(model)
    try:
        r = update_object(request,
                          object_id=1,
                          form_class=formclass,
                          model=model,
                          template_name=templatename,
                          post_save_redirect=redirect_to,
                          extra_context=extra_context)
    except Http404, error:
        r = create_object(request,
                          form_class=formclass,
                          model=model,
                          template_name=templatename,
                          post_save_redirect=redirect_to,
                          extra_context=extra_context)
예제 #4
0
def edit(request, object_id):
    extra_context = {'title': u"Editar computador"}
    return create_update.update_object(request, 
                                       object_id = object_id,
                                       model = Computer,
                                       form_class = form(Computer),
                                       template_name = "base_computers.html",
                                       extra_context = extra_context,
                                       post_save_redirect = "/computers/")
예제 #5
0
def edit(request, object_id):
    extra_context = {'title': u"Editar armazenamento"}
    return create_update.update_object( request,
                                        object_id = object_id,
                                        model = Storage,
                                        form_class = form(Storage),
                                        template_name = "storages_edit.html",
                                        extra_context = extra_context,
                                        post_save_redirect = "/storages/list")
예제 #6
0
def edit(request, object_id):
    extra_context = {'title': u"Editar armazenamento"}
    return create_update.update_object(request,
                                       object_id=object_id,
                                       model=Storage,
                                       form_class=form(Storage),
                                       template_name="storages_edit.html",
                                       extra_context=extra_context,
                                       post_save_redirect="/storages/list")
예제 #7
0
def edit_singleton_model(request, templatename, redirect_to, 
                         formclass = None, model = None, extra_context = None):

    if not formclass and model:
        formclass = forms.form(model)
    try:
        return update_object( request, object_id=1, 
                              form_class = formclass, 
                              model = model,
                              template_name = templatename, 
                              post_save_redirect = reverse(redirect_to),
                              extra_context = extra_context )
    except Http404, error:
        return create_object( request, 
                              form_class = formclass, 
                              model = model,
                              template_name = templatename, 
                              post_save_redirect = reverse(redirect_to),
                              extra_context = extra_context )