<commit_before>
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, redirect
from mezzanine.conf import settings
from mezzanine.utils.views import render, paginate

from .models import Link
from .forms import LinkForm


def link_detail(request, slug):
    link = get_object_or_404(Link, slug=slug)
    return render(request, "link_detail.html", {"link": link})


@login_required
def link_create(request):
    link_form = LinkForm(request.POST or None)
    if request.method == "POST" and link_form.is_valid():
        link = link_form.save(commit=False)
        link.user = request.user
        link.save()
        return redirect(link)
    return render(request, "link_form.html", {"link_form": link_form})


@login_required
def link_edit(request, slug):
    queryset = Link.objects.published(for_user=request.user)
    link = get_object_or_404(queryset, slug=slug)
    link_form = LinkForm(request.POST or None, instance=link)
    if request.method == "POST" and link_form.is_valid():
        link = link_form.save()
        return redirect(link)
    return render(request, "link_form.html", {"link_form": link_form})


def link_list(request):
    page = request.GET.get("page", 1)
    per_page = 20
    max_links = settings.MAX_PAGING_LINKS
    links = paginate(Link.objects.all(), page, per_page, max_links)
    return render(request, "link_list.html", {"links": links})

<commit_msg>Allow descriptions<commit_after>
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, redirect
from mezzanine.conf import settings
from mezzanine.utils.views import render, paginate

from .models import Link
from .forms import LinkForm


def link_detail(request, slug):
    link = get_object_or_404(Link, slug=slug)
    return render(request, "link_detail.html", {"link": link})


@login_required
def link_create(request):
    link_form = LinkForm(request.POST or None)
    if request.method == "POST" and link_form.is_valid():
        link = link_form.save(commit=False)
        link.user = request.user
        link.gen_description = False
        link.save()
        return redirect(link)
    return render(request, "link_form.html", {"link_form": link_form})


@login_required
def link_edit(request, slug):
    queryset = Link.objects.published(for_user=request.user)
    link = get_object_or_404(queryset, slug=slug)
    link_form = LinkForm(request.POST or None, instance=link)
    if request.method == "POST" and link_form.is_valid():
        link = link_form.save()
        return redirect(link)
    return render(request, "link_form.html", {"link_form": link_form})


def link_list(request):
    page = request.GET.get("page", 1)
    per_page = 20
    max_links = settings.MAX_PAGING_LINKS
    links = paginate(Link.objects.all(), page, per_page, max_links)
    return render(request, "link_list.html", {"links": links})


{'fraction_non_alphanumeric': 0.11209842788790157, 'fraction_numerical': 0.008202323991797676, 'mean_word_length': 4.226785714285715, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7100617', 'n_tokens_mistral': 955, 'n_tokens_neox': 917, 'n_words': 221}