Esempio n. 1
0
File: views.py Progetto: sm2x/vron
def config_add(request):
    """
    Add new CONFIG

    :param: request
    :param: config_id
    :return: String
    """

    # Instantiates FORM
    form = ConfigForm(request.POST or None)

    # If form was submitted, it tries to validate and save data
    if form.is_valid():

        # Saves User
        config = form.save()
        messages.success(request, 'Config was successfully added.')

        # Redirects with success message
        return HttpResponseRedirect(
            reverse('admin:connector:config_details', args=(config.id, )))

    # Template data
    context = {'form': form, 'cancel_url': reverse('admin:connector:config')}

    # Prints Template
    return render(request, 'connector/admin/config/add.html', context)
Esempio n. 2
0
File: views.py Progetto: DRGC/vron
def config_add(request):
    """
    Add new CONFIG

    :param: request
    :param: config_id
    :return: String
    """

    # Instantiates FORM
    form = ConfigForm(request.POST or None)

    # If form was submitted, it tries to validate and save data
    if form.is_valid():

        # Saves User
        config = form.save()
        messages.success(request, "Config was successfully added.")

        # Redirects with success message
        return HttpResponseRedirect(reverse("admin:connector:config_details", args=(config.id,)))

    # Template data
    context = {"form": form, "cancel_url": reverse("admin:connector:config")}

    # Prints Template
    return render(request, "connector/admin/config/add.html", context)
Esempio n. 3
0
File: views.py Progetto: sm2x/vron
def config_edit(request, config_id):
    """
    Edit CONFIG data

    :param: request
    :param: config_id
    :return: String
    """
    # Identifies database record
    config = get_object_or_404(Config, pk=config_id)

    # Instantiates FORM
    form = ConfigForm(request.POST or None, instance=config)

    # When form is submitted , it tries to validate and save data
    if form.is_valid():
        form.save()
        messages.success(request, 'Config was successfully updated.')
        return HttpResponseRedirect(
            reverse('admin:connector:config_details', args=(config_id, )))

    # Template data
    context = {
        'form': form,
        'cancel_url': reverse('admin:connector:config_details',
                              args=(config_id, ))
    }

    # Prints Template
    return render(request, 'connector/admin/config/edit.html', context)
Esempio n. 4
0
File: views.py Progetto: DRGC/vron
def config_edit(request, config_id):
    """
    Edit CONFIG data

    :param: request
    :param: config_id
    :return: String
    """
    # Identifies database record
    config = get_object_or_404(Config, pk=config_id)

    # Instantiates FORM
    form = ConfigForm(request.POST or None, instance=config)

    # When form is submitted , it tries to validate and save data
    if form.is_valid():
        form.save()
        messages.success(request, "Config was successfully updated.")
        return HttpResponseRedirect(reverse("admin:connector:config_details", args=(config_id,)))

    # Template data
    context = {"form": form, "cancel_url": reverse("admin:connector:config_details", args=(config_id,))}

    # Prints Template
    return render(request, "connector/admin/config/edit.html", context)