Exemplo n.º 1
0
def archive(request):
    print ":::", request.user
    links = Link.objects.filter(user=request.user, is_archived=True)

    query = ''
    form = LinkSearchForm(request.GET)
    if form.is_valid():
        query = form.cleaned_data['q']
        links = links.filter(url__contains=query)
    form = LinkSearchForm()

    context = {'links': links, 'form': form, 'query': query}
    return render(request, 'links/index.html', context)
Exemplo n.º 2
0
def index(request):
    links = Link.objects.all()
    if request.user.is_authenticated():
        links = links.filter(user=request.user, is_archived=False)
    else:
        links = links.filter(is_public=True)

    query = ''
    form = LinkSearchForm(request.GET)
    if form.is_valid():
        query = form.cleaned_data['q']
        links = links.filter(url__contains=query)
    form = LinkSearchForm()

    context = {'links': links, 'form': form, 'query': query}
    return render(request, 'links/index.html', context)