Пример #1
0
def disable_link(request):
    if request.method == "POST":
        form = DisableLinkForm(data=request.POST)
        if form.is_valid():
            data = form.cleaned_data
            link_token = data['token']

            # Disable the token
            sl = ShortLink.find(token=link_token)
            if not sl.disabled:
                sl.disable()
            else:
                sl.enable()

    return redirect(reverse(links_info, args=[link_token]))
Пример #2
0
def delete_link(request):
    if request.method == "POST":
        form = DisableLinkForm(data=request.POST)
        if form.is_valid():
            data = form.cleaned_data
            link_token = data['token']

            # Delete the token

            ul = UserLink.objects.get(token=link_token)
            ul.delete()
            sl = ShortLink.find(token=link_token)
            sl.delete()
            return redirect(reverse(links_index))
    else:
        return redirect(reverse(links_info, args=[link_token]))