コード例 #1
0
ファイル: views.py プロジェクト: sm2x/vron
def key_edit(request, key_id):
    """
    Edit CONFIG data

    :param: request
    :param: key_id
    :return: String
    """
    # Identifies database record
    key = get_object_or_404(Key, pk=key_id)

    # Instantiates FORM
    form = KeyForm(request.POST or None, instance=key)

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

    # Gets base key to prepend to all keys
    config = get_object_or_false(Config, pk=settings.ID_CONFIG_BASE_API_KEY)
    base_key = config.value

    # Template data
    context = {
        'form': form,
        'cancel_url': reverse('admin:connector:key_details', args=(key_id, )),
        'base_key': base_key
    }

    # Prints Template
    return render(request, 'connector/admin/key/edit.html', context)
コード例 #2
0
ファイル: views.py プロジェクト: DRGC/vron
def key_edit(request, key_id):
    """
    Edit CONFIG data

    :param: request
    :param: key_id
    :return: String
    """
    # Identifies database record
    key = get_object_or_404(Key, pk=key_id)

    # Instantiates FORM
    form = KeyForm(request.POST or None, instance=key)

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

    # Gets base key to prepend to all keys
    config = get_object_or_false(Config, pk=settings.ID_CONFIG_BASE_API_KEY)
    base_key = config.value

    # Template data
    context = {"form": form, "cancel_url": reverse("admin:connector:key_details", args=(key_id,)), "base_key": base_key}

    # Prints Template
    return render(request, "connector/admin/key/edit.html", context)
コード例 #3
0
ファイル: views.py プロジェクト: DRGC/vron
def key_add(request):
    """
    Add new CONFIG

    :param: request
    :param: key_id
    :return: String
    """

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

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

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

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

    # Gets base key to prepend to all keys
    config = get_object_or_false(Config, pk=settings.ID_CONFIG_BASE_API_KEY)
    base_key = config.value

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

    # Printss Template
    return render(request, "connector/admin/key/add.html", context)
コード例 #4
0
ファイル: views.py プロジェクト: sm2x/vron
def key_add(request):
    """
    Add new CONFIG

    :param: request
    :param: key_id
    :return: String
    """

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

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

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

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

    # Gets base key to prepend to all keys
    config = get_object_or_false(Config, pk=settings.ID_CONFIG_BASE_API_KEY)
    base_key = config.value

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

    # Printss Template
    return render(request, 'connector/admin/key/add.html', context)